EmbeddedRelated.com
Forums

code for SPI test for MSP430

Started by Unknown July 3, 2008
can anybody guide me to write SPI communication test code for MSP430?
On 03/07/2008 sambitsarkar@gmail.com wrote:

> can anybody guide me to write SPI communication test code for MSP430?
You'll need to tell us if this is homework or a commercial project, as the consultancy rates will vary. -- The Force is dark on one side, light on the other and holds the world together. Hmmm, just like Gaffer Tape then.
>can anybody guide me to write SPI communication test code for MSP430? >
The examples can be downloaded at msp430.com, in the Code Examples tab. However, using the MSP430 as a spi master: I have found it best to only use the RX ISR, and leave the transmit interrupt off. SPI always transmits a byte when it receives a byte, so when you get a RX interrupt it means both the transmit register is ready for another byte, and the receiver buf has a byte ready for you to read out. And in this case its best to start the transfer by writing to the TXBUFx. The transfer ends when the RX ISR doesnt put another byte into the TXBUFx. You also need to consider whether your slave needs a chipselect to toggle states after every byte, or every 16bits or whatever. So the code to drive the SPI depends heavily on what the other side needs. The example code on msp430.com website is a good basic start.