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.

28235 McBSP in SPI Mode with FIFO

Other Parts Discussed in Thread: CONTROLSUITE

I have a 25 kHz control loop kicked off by an A/D conversion.  At the beginning of this loop I set a GPIO chip select line, and transmit six 16-bit words of data over SPI.  With the 2809 processor, I configured the SPI to use the transmit FIFO.  At the beginning of my control cycle I set the chip select I/O pin and write the six words to SPITXBUF.  The six words of data stream out over SPI in the order I wrote them to SPITXBUF.  This works well.

I'm struggling with how to duplicate this functionality with the 28235's McBSP in SPI mode.  It's set to have a frame size of six words, 16 bits per word. I'm very close to having it set up properly because I'm receiving data on the other end.  However, I don't know how to get the six different words of data to be sent.  When I write the words to DXR1 as I would have to SPITXBUF, it just sends the last word I write to DXR1 six times.  My understanding from the reference guide is that there is no FIFO for the McBSP.

Is there any way I can do what the SPI transmit FIFO does using the McBSP?  If not, what use is it to set the transmit frame size?  Do I have to use DMA to do this?  If so, how can I configure it to trigger properly and keep the correct timing of the chip select line?  Note that all I'm doing is streaming out these six words of data; I'm not receiving anything.

If there are any examples or application notes that could help out with this, that would be great.  The McBSP is pretty flexible and I found the reference guide to be kind of confusing and not clear about how buffering and DMA interaction work.

Thanks in advance for any insight anyone can provide.

 

  • Jon:

    You are correct - on the 2823x, there is no FIFO for the McBSP.  There are some limitations with using McBSP in SPI mode - one of which is that you cannot use the frame length feature of the McBSP. Table 6-1 "Bits Used to Enable and Configure the Clock Stop Mode" indicateshow to set up the McBSP in SPI mode, and you must use a single-phase transmit frame (XPHASE=0) and a transmit frame length of 1 serial word (XFRLEN1 = 0).

    Your options for transmitting from McBSP in SPI mode include:

    1. Sending a single word at a time after polling SPCR2[XRDY] to see if the transmit buffer is ready for the next word.
    2. Using the DMA to send multiple words at a time.

    In the 2823x device_support examples in controlSUITE, please see the mcbsp_spi_loopback example on how to configure the McBSP in SPI mode.  To determine how to configure the DMA for use with the McBSP (in normal or SPI mode), see the mcbsp_loopback_dma example.  This will allow you to have a buffer of 6 words - then trigger the DMA off of XRDY, and it will automatically transmit the 6 words through the McBSP.

    Hope this helps!

  • Thanks Chrissy.  I was able to get it working after looking at the examples you suggested.