|
|
| Line 23: |
Line 23: |
| | | | |
| | | | |
| − | <br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #008000;">'in this demo we only use the second SPI interface</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Config</span><span style="font-size: 11pt; font-family: 'Consolas';">Spi1 </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">Hard </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">Interrupt </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Off</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">Data_order </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">Msb </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">Master </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">Yes </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">Polarity </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Low</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">Phase </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">0 </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">Clockrate </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">128</span><br/><span style="font-size: 11pt; font-family: 'Consolas';"> </span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #008000;">'second SPI</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Spi1init</span><br/><span style="font-size: 11pt; font-family: 'Consolas';">B </span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas';">5</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Spi1out</span><span style="font-size: 11pt; font-family: 'Consolas';">A</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">(</span><span style="font-size: 11pt; font-family: 'Consolas';">1</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">)</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">B</span><br/><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Spi1in</span><span style="font-size: 11pt; font-family: 'Consolas';">A</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">(</span><span style="font-size: 11pt; font-family: 'Consolas';">1</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">)</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">,</span><span style="font-size: 11pt; font-family: 'Consolas';">B</span><br/><span style="font-size: 11pt; font-family: 'Consolas';">A</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">(</span><span style="font-size: 11pt; font-family: 'Consolas';">1</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">)</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">=</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #000080;">Spi1move</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">(</span><span style="font-size: 11pt; font-family: 'Consolas';">a</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">(</span><span style="font-size: 11pt; font-family: 'Consolas';">2</span><span style="font-size: 11pt; font-family: 'Consolas'; color: #ff0000;">))</span> | + | |
| | | | |
| | + | <source lang="bascomavr"> |
| | + | 'in this demo we only use the second SPI interface |
| | + | Config Spi1 = Hard , Interrupt = Off , Data_order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 128 |
| | + | |
| | + | 'second SPI |
| | + | Spi1init |
| | + | B = 5 |
| | + | Spi1out A(1) , B |
| | + | Spi1in A(1) , B |
| | + | A(1) = Spi1move(a(2)) |
| | + | </source> |
| | | | |
| − | | + | <br/>{{Languages}} |
| − | {{Languages}} | + | |
| | | | |
| | [[Category:BASCOM Language Reference]] | | [[Category:BASCOM Language Reference]] |
In order to use the second SPI which is named SPI1, you have to add a '1' to the SPI commands :
The statements above link to the description of the SPI statements (SPI0).
'in this demo we only use the second SPI interface
Config Spi1 = Hard , Interrupt = Off , Data_order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 128
'second SPI
Spi1init
B = 5
Spi1out A(1) , B
Spi1in A(1) , B
A(1) = Spi1move(a(2))