The S32K144 serial communication received data cannot be extracted. I'm working on a microcontroller serial communication linkage function between a DWIN touchscreen and an S32K microcontroller. When the touchscreen sends data and the microcontroller receives and judges the data, I want to extract the 9th bit of the data for judgment and to send different CAN data accordingly. However, I'm unable to successfully extract the data. I would appreciate any guidance from experienced developers. Re: S32K144串口通信接收的数据提不出 Hello @ffdsg,
I have no experience with DWIN touchscreens, however, from a quick search, it seems that the frame structure does not use the '\n' marker for end-of-frame, rather it sends the first two headers (5A & A5), followed by the length of the frame (06).
So, most likely you can edit your UART callback to stop reception with the third byte, something like so:
void LPUART1_RX_ISR(void *driverState, uart_event_t event, void *userData)
{
(void)driverState;
(void)userData;
if (event == UART_EVENT_RX_FULL)
{
bufferIdx++;
if (bufferIdx >= 3) {
uint8_t frameLen = buffer[2]; /* number of bytes after length byte */
uint8_t totalLen = 3 + frameLen; /* header(2) + length(1) + payload */
if (bufferIdx >= totalLen) {
/* Full frame received */
memcpy(rxdata, buffer, totalLen);
keyNum = rxdata[8]; /* 9th byte*/
memset(buffer, 0, sizeof(buffer));
bufferIdx = 0;
trigger = 1;
LPUART_DRV_ReceiveData(INST_LPUART1, buffer, 1);
return;
}
}
LPUART_DRV_SetRxBuffer(INST_LPUART1, &buffer[bufferIdx], 1U);
}
}
This should make sure you are always reading the 9th byte.
Also, inside your routine, you have commented out the following line:
//if (keyNum==0X01) {
Meaning that the CAN message is always the same, no matter what the 9th byte says.
Unfortunately, DWIN touchscreens are third party devices, out of our support scope, and we do not provide any routines with said hardware. You will need to implement and test these changes with your setup.
Best regards, Julián
記事全体を表示