MQX SPI multi chip select problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MQX SPI multi chip select problem

1,103 次查看
terence_kong
Contributor II

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?  

0 项奖励
回复
1 回复

1,089 次查看
danielchen
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复