View previous topic :: View next topic |
Author |
Message |
steamydave
Joined: 06 May 2009 Posts: 39
|
Posted: Thu Mar 31, 2016 10:47 am Post subject: SPI - before I get confused |
|
|
I have looked at the SPI instructions and I understand the basic theory, even seen an interesting video explaining the wave forms etc.
However, I'm a little unclear as to the basics of how BASCOM works with it, and the help example don't quite explain it.
Code: |
Spiinit
B = 5
Spiout A(1) , B
Spiin A(1) , B
A(1) = Spimove(a(2))
|
For example, do the chips wait for a reply, go should the software loop around until a result arrives? In the example from the help here, does the programe wait at each stage of the input.
Also can you mix and match items in the config lines between hardware and software configs?
Quote: |
CONFIG SPI|SPISOFT = SOFT, DIN = PIN, DOUT = PIN , SS = PIN|NONE, CLOCK = PIN , SPIIN=value , MODE=mode, speed=speed, setup=setup
CONFIG SPI|SPIHARD = HARD, INTERRUPT=ON|OFF, DATA_ORDER = LSB|MSB , MASTER = YES|NO , POLARITY = HIGH|LOW , PHASE = 0|1, CLOCKRATE = 4|16|64|128 , NOSS=1|0 , SPIIN=value
Example for Software SPI
Config Spi = Soft , Din = Pinb.0 , Dout = Portb.1 , Ss = Portb.2 , Clock = Portb.3
Example for Hardware SPI, 1 slave
Config Spi = Hard, Interrupt = Off, Data_Order = Msb, Master = Yes, Polarity = High, Phase = 1, Clockrate = 4, Noss = 0
|
How do you make the soft version a master - can you add the "MASTER=YES" from the hard syntax?
Many thanks,
David
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Mar 31, 2016 3:52 pm Post subject: Re: SPI - before I get confused |
|
|
steamydave wrote: | However, I'm a little unclear as to the basics of how BASCOM works with it, and the help example don't quite explain it. |
If you understand how SPI works, you automatically understand how the commands work.
Spiout clocks data out, don't cares about the incoming, Spiin clocks data in, while sending out dummy data, Spimove takes care about outgoing and incoming data at the same.
Quote: | go should the software loop |
Huuh?
Quote: | Also can you mix and match items in the config lines between hardware and software configs? |
No, these are options for each of the versions, if an option would be available for both versions, it would be listed in both.
Quote: | How do you make the soft version a master - can you add the "MASTER=YES" from the hard syntax? |
No, as stated above. And would you have read the help, you would have noticed that the soft version is master-only:
Quote: | SPI SOFT
for software emulation of SPI
...
Only works in master mode |
|
|
Back to top |
|
|
steamydave
Joined: 06 May 2009 Posts: 39
|
Posted: Thu Mar 31, 2016 4:18 pm Post subject: |
|
|
Thank you for your quick reply - I think.
David |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Mar 31, 2016 7:39 pm Post subject: |
|
|
steamydave wrote: | - I think. |
We all do sometimes. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|