Hi Guys,
I'm trying to communicate via SPI with a stepper motor module.In my project I using FRDM MKE02Z, KDS and PE Syncro Master component. So, the issue I found is related with the interrupt OnTxChar, it seems that occurs before complete a char transmit.
Between the commands i need to toggle the CS and this is performed manually (cause I using CPOL = 1 and CPHA =1 and this mode does not allow automatic toggle). But after some problems i plugged a logic analyzer to verify and saw that interrupt "OnTxChar" is triggered before the char is totally finalized.
Image attached shows 2 commands, i toggle one auxiliar pin at "OnTxChar" to verify what time this occurs (channel 6).
void SPI_SM_OnTxChar(void)
{
/* Write your code here ... */
CS_SPI_SetVal();
CS_SPI_ClrVal();
}
Is there a way, with interrupts or pooling mode, to trigger the final of char transmit?
Thank in advance guys
Hi
Since the Tx is buffered it is normal that it is generating a Tx interrupt early in the byte transmission so that the FW can supply the next byte of data for the buffer in good time so that there are no unnecessary time gaps between bytes.
If you switch to the RX FULL interrupt after you have completed sending the final byte of data you will then have an interrupt at the end of the final byte that can be used for CS control.
An alternative is to generally use the RX interrupt rather than the Tx interrupt. This will give you the timing that you need for the last byte - its drawback is that it doesn't keep the Tx buffer filled and so you will find that there is a little extra delay between byte transmissions in the frame - often this is not a problem since the speed of transfer is not critical and so gives the simplest overall solution.
Regards
Mark
Hi michaeltoaldo,
According to the SPI Status Register (SPIx_S), there is no such flag for "OnTxChar", seems that only "OnFreeTxBuf" available.
I didn't find that automatic toggle is not allowed in CPOL = 1 CPHA = 1 mode, have you tried it?
Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------