Dear all,
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Dear all,
An additional resource for sample code for SPI and CC2500 register access is to look at "AN049 - Software for CC1100/CC2500 and MSP430 - Examples and function library" (swra141 -- read abstract here). It is not written for the eZ430-RF2500, but you should be able to re-use the code and port it to your MSP430F2274 without too much work.
One general thing about SPI: checking for the TXIFG flag only indicates that the transmit buffer is ready for a new data byte. It does not mean that the last byte has been sent. It is still in the oputput shift register and being sent when TXIFG is flagged.
You should check for RXIFG coming up, as this happens when the last bit a synchroneously incoming byte has been received and therefore the last bit of the outgoing shift register has been sent. If you deselect the slave CD line, you disable its receiver before it got the last byte. Unfortunately stuffing the TX register and getting RXIFG flagged overlaps (as there is always one more byte in the queue). So either you wait until you received a byte after stuffing TXBUF, which wastes some time as the sending chain is interrupted for some MCLK cycles, or you have to disable interrupts and carefully align the process. But this is only necessary if you have to transfer large amounts of data and/or running the SPI at maximum clock (>=MCLK)
The question 'should I send the NOP' can only be answered with a clear YES. If you're not sending anything, you don't receive anything. SPI is synchroneous. One bit sent is one bit received. And one bit to receive requires one bit sent. By sending a dummy byte (such as a NOP code) you're at the same time receiving the answer to your last command. Also, keep in mind that teh bytes you receive are the bytes requested by the previous command. It's not a 'send a command and receive an answer' but rather 'send a command and simultaneously receive the answer to the previous'. This is completely different to the UART mode, where you send something and will eventually receive something. Or the I2C mode, where sending and receiving is controlled by the addressing mode and only one or the other is happening at the same time in a controlled order.
P.s.: you can also check for UCxySTAT&UCBUSY if you want to know whether sending (and receiving) is actually finished in master mode.
Hi ever one
i am final year student ,i doing my final year project "Remote Monitoring Systems " .i am using AD7763 and eZ430-Rf2500T,i am try to communicate wth SPI..
i am finding difficult write code for spi..is there any chance to help me out in this..i used the sample code but still not geting any answer.
AD7763 is got 4 spi
thankx
SPI is quite simple (as long as you're master) and straightforward. Once you understood how SPI works.
The mistake most newbies make is that SPI work quid pro quo. That means, to get a byte you have to send a byte. Even if it is a dummy. And when you send a byte, you'll get a byte (even if it is a dummy). if you don't send something, you will never get something.
The second problem most people have is to understand when what happens. Caused by the double-buffering inside the SPI hardware. When you write a byte, it is moved from the TX buffer into the output shift register and the TX buffer is immediately free again. So the write side is always up to 2 bytes ahead of the receiving side.
Third cornerstone is the addressing of the slave. You'll need a separate IO line to address msot slaves. This line resets the protocol, synchronizes the byte transfers (there are not startbits or stopbits as on RS232) and ends the protocol (or even interrupts it).
The rest (inlcuding the SPI setup ) is easy:
Implementing the slaves data protocol, hopwever, might prove a bit more difficult (e.g. talking to an SD card)
**Attention** This is a public forum