Figure 1 is a screenshot of debugging, compared to serial port monitoring
Figure 2
/*==================================================================================================
* Project : RTD AUTOSAR 4.7
* Platform : CORTEXM
* Peripheral : S32K3XX
* Dependencies : none
*
* Autosar Version : 4.7.0
* Autosar Revision : ASR_REL_4_7_REV_0000
* Autosar Conf.Variant :
* SW Version : 3.0.0
* Build Version : S32K3_RTD_3_0_0_D2303_ASR_REL_4_7_REV_0000_20230331
*
* Copyright 2020 - 2023 NXP Semiconductors
*
* NXP Confidential. This software is owned or controlled by NXP and may only be
* used strictly in accordance with the applicable license terms. By expressly
* accepting such terms or by downloading, installing, activating and/or otherwise
* using the software, you are agreeing that you have read, and that you agree to
* comply with and are bound by, such license terms. If you do not agree to be
* bound by the applicable license terms, then you may not retain, install,
* activate or otherwise use the software.
==================================================================================================*/
/**
* @file main.c
*
* @addtogroup main_module main module documentation
* @{
*/
/* Including necessary configuration files. */
#include "Clock_Ip.h"
#include "CDD_Rm.h"
#include "Dma_Ip.h"
#include "Clock_Ip.h"
#include "Siul2_Port_Ip.h"
#include "Siul2_Dio_Ip.h"
#include "Lpuart_Uart_Ip.h"
#include "IntCtrl_Ip.h"
uint8_t RxData[128];
uint8_t TxData[128]={0x05, 0x04, 0x00, 0x00, 0x00, 0x02, 0x70, 0x4F};
void TestDelay(uint32 delay)
{
static volatile uint32 DelayTimer = 0;
while (DelayTimer < delay)
{
DelayTimer++;
}
DelayTimer = 0;
}
void UART2_Callback(const uint8 HwInstance,
const Lpuart_Uart_Ip_EventType Event, void *UserData)
{
(void) UserData;
if (LPUART_UART_IP_INSTANCE_USING_2 == HwInstance)
{
switch (Event)
{
case LPUART_UART_IP_EVENT_RX_FULL:
Lpuart_Uart_Ip_SetRxBuffer(LPUART_UART_IP_INSTANCE_USING_2, RxData, 9);
if(5==RxData[0])
{
RxData[9] = 0x55;
}
break;
case LPUART_UART_IP_EVENT_TX_EMPTY:
break;
case LPUART_UART_IP_EVENT_END_TRANSFER:
Siul2_Dio_Ip_WritePin(SEL_PORT, SEL_PIN, 0);
break;
case LPUART_UART_IP_EVENT_ERROR:
break;
}
}
}
int main(void)
{
/* Write your code here */
Clock_Ip_Init(Clock_Ip_aClockConfig);
Siul2_Port_Ip_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
Siul2_Dio_Ip_WritePin(EN_PORT,EN_PIN,1);
Rm_Init(&Rm_Config);
Dma_Ip_Init(&Dma_Ip_xDmaInitPB);
Lpuart_Uart_Ip_Init(LPUART_UART_IP_INSTANCE_USING_2, &Lpuart_Uart_Ip_xHwConfigPB_2);
Lpuart_Uart_Ip_AsyncReceive(LPUART_UART_IP_INSTANCE_USING_2, RxData, 9);
IntCtrl_Ip_Init(&IntCtrlConfig_0);
while (1)
{
TestDelay(4800000);
Siul2_Dio_Ip_WritePin(SEL_PORT, SEL_PIN, 1);
Lpuart_Uart_Ip_AsyncSend(LPUART_UART_IP_INSTANCE_USING_2, TxData, 8);
}
return 0;
}
/** @} */
Solved! Go to Solution.
Hi @ZDDL,
I've downloaded your project and tested reception this way:
I only modified the buffer size (to 8), and commented these lines from the Full Rx Event:
if(5==RxData[0])
{
RxData[9] = 0x55;
}
As well as modifying the pins to PTA29 and PTA30 to test this in the S32K3X4-T172 EVB.
It seems reception is working properly, with or without the implemented delay:
Best regards,
Julián
Hi @ZDDL,
Best regards,
Julián.
Thanks for your reply. I modified the Tx and Rx buffer definition according to your suggestion,
but the received data was still incorrect.
and, if i comment out this line("// TestDelay(4800000);"), it will send an additional unwanted frame before normal transmission, i don't know why.
Hi @ZDDL,
I've downloaded your project and tested reception this way:
I only modified the buffer size (to 8), and commented these lines from the Full Rx Event:
if(5==RxData[0])
{
RxData[9] = 0x55;
}
As well as modifying the pins to PTA29 and PTA30 to test this in the S32K3X4-T172 EVB.
It seems reception is working properly, with or without the implemented delay:
Best regards,
Julián
I used your modified project and only modified the port to fit my board, but the data I received was still wrong.
When I was compiling the project, there was such a warning, I don't know if this is the root cause.
You are right, it is a hardware issue, because I connected the logic analyzer on the TX and RX of the serial port, and the communication was normal after disconnecting the logic analyzer.
so,thanks a lot.