Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem in spi with bascom

Status
Not open for further replies.

majid_valentine

Junior Member level 3
Joined
Dec 10, 2006
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,430
bascom spi

hi all

what is problem in my program???

data dont recived correctly by slave!!!!!!!!!!!!!

master program:

$regfile = "m32def.dat"
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = Pina.6 , Db7 = Pina.7 _
, E = Pina.3 , Rs = Pina.2
Config Lcd = 16 * 4
Config Spi = Hard , Interrupt = On , Data Order = Lsb , Master = Yes , _
Polarity = High , Phase = 1 , Clockrate = 4
Enable Spi
Dim A As Byte
Spiinit
For A = 0 To 10
Spiout A , 1
Wait 1
Next A

End 'end program

slave program:


$regfile = "m16def.dat"
$crystal = 8000000
Config Spi = Hard , Interrupt = On , Data Order = Lsb , Master = No , _
Polarity = High , Phase = 0 , Clockrate = 4
Config Lcdpin = Pin , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = Pina.6 , Db7 = Pina.7 _
, E = Pina.3 , Rs = Pina.2
Config Lcd = 16 * 4
Enable Interrupts
Enable Spi
On Spi Yes
Dim A As Byte
Spiinit

Cls
Home Upper
Lcd " NO SPI"
Home Lower
Do
Wait 1
Loop
End 'end program
'--------------
Yes:
Disable Interrupts
Spiin A , 1
Lcd A

Enable Interrupts
Return

Added after 1 hours 10 minutes:

i realy need to help?????

any body can't help me?????

pleas!!!!!!!!
 

bascom avr spi

any bady can not help me?????

i am realy sorry for myself!!!!!!!!!!
 

spi bascom

well majid as i see ur code in salve is missing an important syntax . u most use :

enable interrupts
enable spi
on spi yes


and whats wrong with u . u Can NOT use enable interrupts AND disable it too . enable interrupts JUST activate the Global interrupts not disable it .
 

bascom config spi

hi my friend

tanks for notic

i enable interrupts and enable spi and... in slave

program!!!!!!!!!!!!

is not enough???!!!
 

on spi bascom

Hi,
Since I am not an expert in BASCOM, and I assume you are, I will lend my blank head to you to solve your problem.

1.Initially, I would like to make the code work without interrupt. Accordingly, in the corrected code given below, I have made Interrupt = OFF and removed all interrupt related statements.
2. In the slave program, I have moved 'Dim A As Byte' statement to the top, it could be anywhere above 'Do Loop' since Do-loop needs it.
3.I have shifted the LCDINIT to the top, but I do not see you defining RD/WR- pin, it is required.
4. The received data is written on second line start of LCD, does the cursor move automatically to right on each character?
5. Is ' On Spi Yes ' a standard way to call a subroutine 'YES', I assumed that it looks for a character to be available in SPI receive register and executes 'YES' routine if a character is found.
6.The Slave program now mainly waits in the do loop looking for a character and send it to LCD if one found.
7. How is the hardware connection done?, the Master and Slave programs are assumed to be running simultaneously in two different CPUs and the two CPUs are connected using the SPI BUS, Since each CPU is fully busy doing either transmission or reception.

Please let me know if the code is working OK?

Master program:

$regfile = "m32def.dat"
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = Pina.6 , Db7 = Pina.7 _
, E = Pina.3 , Rs = Pina.2
Config Lcd = 16 * 4
Config Spi = Hard , Interrupt = OFF , Data Order = Lsb , Master = Yes , _
Polarity = High , Phase = 1 , Clockrate = 4
Enable Spi
Dim A As Byte
Spiinit
For A = 0 To 10
Spiout A , 1
Wait 1
Next A

End 'end program

slave program:

$regfile = "m16def.dat"
$crystal = 8000000
Dim A As Byte
Config Lcd = 16 * 4
Config Lcdpin = Pin , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = Pina.6 , Db7 = Pina.7 _
, E = Pina.3 , Rs = Pina.2
Cls
Home Upper
Lcd " NO SPI"
Home Lower

Config Spi = Hard , Interrupt = OFF , Data Order = Lsb , Master = No , _
Polarity = High , Phase = 0 , Clockrate = 4

Enable Spi
Spiinit

Do
On Spi Yes
Wait 1
Loop
End 'end program
'--------------
Yes:
Spiin A , 1
Lcd A
Return


Regards,
Laktronics
 

avr spi problem spiin spiout

hi laktronics
this is wrong ... we CAN NOT use on interrupts in do....loop


Do
On Spi Yes
Wait 1
Loop
End 'end program
 

spi bascom probleme

Hi Segmex,
That is exactly what I wanted him to check, I want an event driven subroutine call and not an interrupt routine. I have already advised him to disable interrupt. Mine was not a solution, but a way to make him help himself. If you have the right answer, please help him.
Regards,
Laktronics
 

bascom spi-slave

$regfile = "m32def.dat"
$crystal = 8000000
$regfile = "m16def.dat"
Config Lcdpin = Pin , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = Pina.6 , Db7 = Pina.7 _
, E = Pina.3 , Rs = Pina.2
Config Lcd = 16 * 4
Config Spi = Hard , Interrupt = OFF , Data Order = Lsb , Master = Yes , _
Polarity = High , Phase = 1 , Clockrate = 4
Spiinit
Dim A As Byte
Do
For A = 0 To 10
Spiout A , 1
Wait 1
Next A
Loop
End 'end program

slave program:

$regfile = "m16def.dat"
$crystal = 8000000
Dim A As Byte
Config Lcd = 16 * 4
Config Lcdpin = Pin , Db4 = Pina.4 , Db5 = Pina.5 , Db6 = Pina.6 , Db7 = Pina.7 _
, E = Pina.3 , Rs = Pina.2
Cls
Home
Lcd " NO SPI"
Lowerline

Config Spi = Hard , Interrupt = On , Data Order = Lsb , Master = No , _
Polarity = High , Phase = 0 , Clockrate = 4
Enable Interrupts
On Spi Yes
Enable Spi
Spiinit

Do

Loop
End 'end program
'--------------
Yes:
Cls
Home
Spiin A , 1
Lcd A
Return


i think this code works for u
 

$regfile enable intrupts

Hi,
Yes, Segmex, his main problem was initiating Interrupt in Master, which was never used. Your code should work.
Regards,
Laktronics.
 

config spi hard

hi laktronics
yes it mybe work
BUT where is majid to tell us that the code is working or NOT !!
 

config spi bascom

hi all

please forgive me.

i was busy this days.....

the circuit is true by simulating with proteus

but when i test it on bredboard dosen't work in

action!!!!!!!

what is problem????



please forgive me if i have mistake in writing

becaus my english is not well
 

master receive bascom spi

Hi Majid,
Your problem may be also due to the mistake in connections, please post the circuit.

Hello Segmex, I have some doubts regarding Bascom, hope you can clarify:

1. Why is it the pins for RD/WR- for LCD not defined in BASCOM, is it fixed and if so as which?

2. In the manual, the the statement ' SPI INIT ' is explained to configure the pins as only for Master. Does the statement automatically take care for slave, once we specify ' Master = NO ' under CONFIG SPI?

3. The manual also says that the programming of ClockPhase ( Phase = 1/0 under Config SPI) should be set same for both Master and Slave. But in this case, since the master is not receiving any data, it may not be important?

Also please continue to help clear this thread with any ideas you get.

Regards,
Laktronics
 

bascom mehrere spi

mwpiqv.jpg
[/img]
 

spi bascom

Hi Majid,
Some more questions for you, reply back point by point:
1. Is the harware connection otherwise working without SPI?, Like did you run sme diagnostic test like turning on an LED or writing something to LCD on each Micro controller? It is important to ensure this just to see if your crystal/ Reset etc connections are ok.

2. Is it not possible to disconnect SS- pin connection from master and ground it permanently on slave ?

3. If you have answers to some points I posed to Segmex in my post above, you may also clarify.

I will get back after a while, in the mean time, I will also check if Segmex has something to say.
Regards,
Laktronics

Added after 2 hours 48 minutes:

Hi Majid,

Continuing further,

4. You also make clock PHASE = 0 in Master as it is already zero in slave, since it has a relationship with data being sent.

5. Make CLK RATE = 64 in both Master and slave for testing purposes to see if the SPI has got any speed problem.

6.Send displayable ASCII characters for A from master, 0 to 10 will not be printable.

Regards,

Laktronics.
 

$regfile=m32def.dat

hi all

1. Why is it the pins for RD/WR- for LCD not defined in BASCOM, is it fixed and if so as which?

well its simple when u wanna show sth on lcd the WR pin must be grounded .
and its good to know that bascom avr have powerfull libraries for lcd both character and garpgical .


2. In the manual, the the statement ' SPI INIT ' is explained to configure the pins as only for Master. Does the statement automatically take care for slave, once we specify ' Master = NO ' under CONFIG SPI?

yes .



3. The manual also says that the programming of ClockPhase ( Phase = 1/0 under Config SPI) should be set same for both Master and Slave. But in this case, since the master is not receiving any data, it may not be important?

well ... the bascom says that 0 is recommanded and i always use phase=0 .

Added after 1 minutes:

majid_valentine said:

hi majid

are u testing ur circuit with proteus!!!
 

bascom spi hardware

hi segmex

yes i test it by proteus.and it was true

Added after 5 minutes:
 

spi out bascom

ha .....ha
the problem is proteus ..... i know ...

please check the source with real hardware !i!i
 

2 spi bascom

thanks all.

i finally don't can answer from bascom but it work corectly with codvision .
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top