I am having a problem using the multiple SPI CS signals in my K20 application. My application uses SPI0 and addresses two memory devices using 2 CS signals (CS0, and CS1). I had things working for CS0 but CS1 does not seems to work. I am using MQX4.1 and IAR.
In my bsp I changed init_gpio.c by modifying case 0 in the _bsp_dspi_io_init function as shown below.
_mqx_int _bsp_dspi_io_init
(
uint_32 dev_num
)
{
SIM_MemMapPtr sim = SIM_BASE_PTR;
PORT_MemMapPtr pctl;
switch (dev_num)
{
case 0:
/* Configure GPIOD for SPI0 peripheral function */
pctl = (PORT_MemMapPtr)PORTD_BASE_PTR;
pctl->PCR[0] = PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK; /* DSPI0.PCS0 */
pctl->PCR[4] = PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK; /* DSPI0.PCS1 */
pctl->PCR[1] = PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK; /* DSPI0.SCK */
pctl->PCR[2] = PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK; /* DSPI0.SOUT */
pctl->PCR[3] = PORT_PCR_MUX(2) | PORT_PCR_DSE_MASK; /* DSPI0.SIN */
/* Enable clock gate to SPI0 module */
sim->SCGC6 |= SIM_SCGC6_SPI0_MASK;
break;
In my application I open/close the SPI0 port depending upon which of the 2 devices
spif0 = fopen("spi0:0", NULL);
spif1 = fopen("spi0:1", NULL);
Is there any examples of how to properly configure a BSP to use multiple SPI select signals with MQX?
Hi
Please be noted that the value after the colon is the chip select mask value, not the chip select number directly.
If you need to assert CS0 and CS1, this field should be set to 3.
spi_handle = fopen("spi0:3", NULL);
Regards
Daniel