AnsweredAssumed Answered

SPI CHIP SELECT PROBLEM ON MK10DN128VFM5 WITH MQX4.2

Question asked by Tahir Mahmood on Jun 24, 2016
Latest reply on Jun 24, 2016 by soledad

I am using the
following command to do chip select on PTD4 (CS1) and PTC2(CS2) which is
working correctly with microcontroller but it is wrong. The initialization for
CS2 should work with "spi0:3" but it works with spi0:4. Can you tell
me where is the error? Is data sheet wrong or MQX4.2 wrong?



spifd1 = _io_fopen ("spi0:2", NULL); /* CS1 on the bus SPI0 */

spifd2 = _io_fopen ("spi0:4", NULL); /* CS2 on the bus SPI0 */

 

 

I have correctly configured the io pins for SPI. I am sending you the
function which I am using.

 

_mqx_int _bsp_dspi_io_init

(

    uint32_t dev_num

)

{

    SIM_MemMapPtr   sim = SIM_BASE_PTR;

    PORT_MemMapPtr  pctl;

 

    switch (dev_num)

    {

        case 0:

            /*
Configure GPIOD for DSPI0 peripheral function */

            pctl
= (PORT_MemMapPtr)PORTC_BASE_PTR;

 

          
pctl->PCR[2] = PORT_PCR_MUX(2);     /*DSPI0.PCS2   */

          
pctl->PCR[5] = PORT_PCR_MUX(2);     /*DSPI0.SCK    */

          
pctl->PCR[6] = PORT_PCR_MUX(2);     /*DSPI0.SOUT   */

 
pctl->PCR[7] =PORT_PCR_MUX(2);     /* DSPI0.SIN    */

 

pctl= (PORT_MemMapPtr)PORTD_BASE_PTR;

          
pctl->PCR[4] = PORT_PCR_MUX(2);     /*DSPI0.PCS1   */

           

            /*Enable clock gate to DSPI0 module */

      
    sim->SCGC6 |= SIM_SCGC6_SPI0_MASK;

          
break;

 

default:

            /* do nothing if bad dev_num was selected */

          
return -1;

    }

 

    return MQX_OK;

Outcomes