Hi,
I am using the k40 and I am trying to communicate with another chip from Linear Technology. I am looking at the SPI signals coming out of the k40 and I notice that the MOSI pin stays high after the data has been sent out. I want it to remain low after data transmission... Does anybody know how to do this?
I am using the MQX SPI example and have modified it to communicate with the LT chip.
Thanks!
Hi, I am not sure why you want such thing, but unfortunately this cannot be solved by any SPI configuration. SOUT signal always return to high logic in idle state.
Best way how to do is create Chip select function which will be called at begin and at end of transfer.
For example (TWR-K40D100M, SPI0, I configured SOUT pin to input with pulldown):
#define BSP_SPI_MEMORY_SPI_CS 1
_mqx_int set_CS (uint32_t cs_mask, void *user_data)
{
PORT_MemMapPtr pctl;
pctl = (PORT_MemMapPtr)PORTD_BASE_PTR;
pctl->PCR[2] |= PORT_PCR_PE_MASK; /* enable pull-up/down*/
if (cs_mask & BSP_SPI_MEMORY_SPI_CS)
{
pctl->PCR[2] = PORT_PCR_MUX(2)|PORT_PCR_PE_MASK; /* DSPI0.SOUT */
}
else
{
pctl->PCR[2] = PORT_PCR_MUX(1)|PORT_PCR_PE_MASK; /* DSPI0.SOUT as GPIO */
}
return MQX_OK;
}
Inside task:
spifd = fopen (TEST_CHANNEL, NULL);
callback.CALLBACK = set_CS;
if (SPI_OK == ioctl (spifd, IO_IOCTL_SPI_SET_CS_CALLBACK, &callback))
{
printf ("Setting CS callback ...OK\n");
}
…write to SPI
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------