SPI1INIT, SPI1IN, SPI1OUT, SPI1MOVE

From MCS Wiki AVR
(Difference between revisions)
Jump to: navigation, search
(Created page with "Some of the new MEGA processors like ATMEGA328<span style="font-weight: bold;">PB</span> have a second SPI bus. This is not a USART that can work in SPI mode but a full SPI bu...")
 
 
Line 23: Line 23:
 
&nbsp;
 
&nbsp;
  
&nbsp;<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';">&nbsp;</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>
+
&nbsp;
  
 +
<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]]

Latest revision as of 21:12, 17 January 2017

Some of the new MEGA processors like ATMEGA328PB have a second SPI bus. This is not a USART that can work in SPI mode but a full SPI bus.

 

In order to use the second SPI which is named SPI1, you have to add a '1' to the SPI commands :

 

CONFIG SPI1

SPI1INIT

SPI1IN

SPI1OUT

SPI1MOVE

 

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))

Languages   English  
Personal tools
Namespaces
Variants
Actions
Navigation
Language