Hi.
I try to send a CAN message and it works.
But there is a problem.
I send a CAN message only 1 time but several CAN messages are sent. (refer to below picture)
I have to send a CAN message only 1 time.
What should I do?
■ MCU : S32K144(68pin)
■ Picture
- 1 : CAN high at CAN transceiver
- 2 : CAN TX at MCU
■ Code
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "pin_mux.h"
#include "clockMan1.h"
#include "dmaController1.h"
#include "osif1.h"
#include "canCom1.h"
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#define MB (0UL)
#define MSG_ID 0x1B0
/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/
int main(void)
{
/* Write your local variable definition here */
flexcan_data_info_t dataInfo =
{
.data_length = 1U,
.msg_id_type = FLEXCAN_MSG_ID_STD,
.enable_brs = false,
.fd_enable = false,
.fd_padding = 0U
};
uint8_t toggleLED = 0x55;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
/* For example: for(;;) { } */
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT, g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_FORCIBLE);
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
FLEXCAN_DRV_ConfigTxMb(INST_CANCOM1, MB, &dataInfo, MSG_ID);
for(;;)
{
if(GPIO_HAL_ReadPins(PTD)>>0==1)
{
GPIO_HAL_ClearPins(PTC,1<<0);
FLEXCAN_DRV_Send(INST_CANCOM1, MB, &dataInfo, MSG_ID, &toggleLED);
}
else
{
GPIO_HAL_SetPins(PTC,1<<0);
}
}
Hello,
I am not S32K SDK expert, but it looks like you did not receive acknowledge from receiving frame, so your microcontroller repeat the transmission again and again.
What is the connected on your CAN bus? Is there any other device or microcontroller?
Regards,
Martin
Hi.
I connected PCB to VN1630.
Now I solved this problem. I changed CANsend code from for(;;) to LPIT ISR() and above situation was dissappeared.
I thought when I push the button CANsend code was activated several times.
Thank you.