cavebiker cavebiker

K60 32 bit SPI slave problem

Discussion created by cavebiker cavebiker on Jun 12, 2012
Latest reply on Mar 12, 2013 by sudhir prabhu

: •  My problem is, when I setup a Kinetis K60 or K70 part for 32 bit SPI slave, the SPI slave replies to a 32 bit master with 32 bits, which is correct except the lower 16 bits get transmitted twice, meaning the top 16 bits are never transmitted. i.e. I write (example) 0x12345678 to the 32 bit PIx_PUSHR_SLAVE register, and what is sent out is 0x56785678, not 0x12345678 as I expect.


•  K60 SPI initialization code:

void Init_SPI_TJ(void)


   SIM->SCGC3    |= (1UL <<  12);  //Enable SPI2     

   SIM->SCGC5    |= (1UL << 12);   //Enable Clock

   SPI2->RSER = 0x00000000;        //No interrupts

   SPI2->CTAR_SLAVE[0] = 0xF8000000; //32 bits slave SPI

   SPI2->MCR  = 0x40000000;         //Run SPI


   PORTD->PCR[11] = (1UL << 9);     //SPI CS0

   PORTD->PCR[12] = (1UL << 9);     //SPI Clock

   PORTD->PCR[13] = (1UL << 9);     //SPI MOSI

   PORTD->PCR[14] = (1UL << 9);     //SPI MISO



•  My test code main loop simply stuffs the SPI2_PUSHR_SLAVE register with 32 bits of TX data.


•  When a SPI master sends out a 32 bit frame, my K60 SPI slave sends out the bottom 16 bits twice, and never sends the top 16 bits.

•   I have been running this in 16 bit SPI slave mode for weeks and everything has worked perfect, but I need it to run 32 bits


If anyone has any ideas I will appreciate hearing them.

Thank you in advance for your help,