AnsweredAssumed Answered

MQX SPI Drivers w/DMA usage on MQX version 4.0.2 with K60

Question asked by Mark Grillo on Nov 6, 2014
Latest reply on Nov 18, 2014 by Mark Grillo

Hello,

 

Are there any issues with MQX 4.0.2 with the TWR-K60D100M when using SPI2 DMA drivers? Based on the MQX examples I can successfully see data write, (SOUT  <PTB22>), while doing a full duplex " ioctl (spifd, IO_IOCTL_SPI_READ_WRITE, &rw)". But RXFIFOs nor the memory location pointed to see the data on SIN, (PTB23).

 

 

Here are some of the lines of code I'm using in my project:

*******************************************************************************

/* Configure PINs */

                  PORTB_PCR20 = (0|PORT_PCR_MUX(2));                           // Alt2 //CS

                  PORTB_PCR21 = (0|PORT_PCR_MUX(2));                           // Alt2 //CLK

                  PORTB_PCR22 = (0|PORT_PCR_MUX(2));                           // Alt2 //SOUT

                  PORTB_PCR23 = (0|PORT_PCR_MUX(2)|PORT_PCR_IRQC(3));                // Alt2 //SIN //DMA both edges ?

 

/* Open the SPI driver */

    spifd = fopen (TEST_CHANNEL, NULL);  // #define TEST_CHANNEL  "spi2:"

//baud, clock mode, endian, transfer mode are from the MQX example.

 

    /* Test simultaneous write and read */

    memset (send_buffer, 0, sizeof (send_buffer));

    memset (recv_buffer, 0, sizeof (recv_buffer));

    send_buffer[0] = SPI_MEMORY_READ_DATA;

    for (i = SPI_MEMORY_ADDRESS_BYTES; i != 0; i--)

    {

send_buffer[i] = (SPI_MEMORY_ADDR1 >> ((SPI_MEMORY_ADDRESS_BYTES - i) << 3)) & 0xFF;

    }

rw.BUFFER_LENGTH = 10;

    rw.WRITE_BUFFER = (char_ptr)send_buffer;

    rw.READ_BUFFER = (char_ptr)recv_buffer;

eips_user_dbprint0("IO_IOCTL_SPI_READ_WRITE ... ");

    if (SPI_OK == ioctl (spifd, IO_IOCTL_SPI_READ_WRITE, &rw))

    {

eips_user_dbprint0("OK\n\r");

    }

    else

    {

eips_user_dbprint0("ERROR\n\r");

    }

    fflush (spifd);

***************************************************************************

 

I can see data from "rw.WRITE_BUFFER" on the wire and it matches.

I removed my slave dice for test purposes and looped back SOUT to SIN and still see nothing but all 0's in buffer rw.READ_BUFFER and SPI2_RXFRx registers. Is the data still stuck in the shift register?

With a break point after the ioctl above SPI register values are:

SPI2_MCR = 0x81fe0000

SPI2_TCR = 0x00fr40000

SPI2_SR = 0xc2000000

SPI2_RSER = 0x03030000

SPI2_POPR = 0x00

SPI2_RXFR0 to 3 = 0x00

 

Any ideas why RX FIFOs are not seeing any data in?

 

Thanks,

Mark

Outcomes