cancel
Showing results for 
Search instead for 
Did you mean: 

CAN transmit error

Dani Prieto
Associate II
Posted on July 05, 2018 at 12:36

Hello

I have a bus with 1 master and 3 slaves, which communicates perfectly without problems.

At the moment we activate the power part of the system, noise starts to be generated and suddenly one of them stops transmitting.

Looking at the CAN_TX/CAN_RX signals in the micro we see that the ACK's are no longer sent, but nevertheless the messages continue to be received on the board and the corresponding functions are still being performed. Debugging we see that the three mailboxes are filled and the following errors appear in CAN_TSR, and it stops sending any messages neither ACK's.

The left one is the correct, and right one is when the error happens.

This is the initialization code:

void CANsetup(void){
//CAN_InitTypeDef CAN_InitStructure;
 //CAN_FilterInitTypeDef CAN_FilterInitStructure;
 /* Configure CAN1 RX pin PA11 */
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //GPIO_Mode_IPU;
 GPIO_Init(GPIOA, &GPIO_InitStructure);
 
 /* Configure CAN1 TX pin PA12 */
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_Init(GPIOA, &GPIO_InitStructure);
 /* Configure CAN1 RS pin PC15 -> =0 */
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 GPIO_Init(GPIOC, &GPIO_InitStructure);
port_set(PORT_C, 15, 0);
 /* Remap CAN1 GPIOs */
 // GPIO_PinRemapConfig(GPIO_Remap_CAN2 , ENABLE); 
 
 /* CAN2 and CAN2 register init */
 CAN_DeInit(CAN1);
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

TestStatus CAN_Interrupt(void){
CAN_InitTypeDef CAN_InitStructure;
 CAN_FilterInitTypeDef CAN_FilterInitStructure;
// uint32_t i = 0;
 /* CAN register init */
 CAN_DeInit(CAN1);

 CAN_StructInit(&CAN_InitStructure);
 /* CAN cell init */
 CAN_InitStructure.CAN_TTCM=DISABLE;
 CAN_InitStructure.CAN_ABOM=DISABLE;
 CAN_InitStructure.CAN_AWUM=DISABLE;
 CAN_InitStructure.CAN_NART=DISABLE;
 CAN_InitStructure.CAN_RFLM=DISABLE;
 CAN_InitStructure.CAN_TXFP=DISABLE;
 CAN_InitStructure.CAN_Mode=CAN_Mode_Normal;
 CAN_InitStructure.CAN_SJW=CAN_SJW_1tq;
 
 /* Baudrate = 250 --500 Kbps */
 CAN_InitStructure.CAN_BS1=CAN_BS1_2tq;
 CAN_InitStructure.CAN_BS2=CAN_BS2_3tq;
 CAN_InitStructure.CAN_Prescaler=12; //12
 CAN_Init(CAN1, &CAN_InitStructure);
 /* CAN filter init */
 CAN_FilterInitStructure.CAN_FilterNumber=0;//33
 CAN_FilterInitStructure.CAN_FilterMode=CAN_FilterMode_IdMask;
 CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;
 CAN_FilterInitStructure.CAN_FilterIdHigh=0x0500<<5;
 CAN_FilterInitStructure.CAN_FilterIdLow=0x0000;
 CAN_FilterInitStructure.CAN_FilterMaskIdHigh=0x07FC<<5;
 CAN_FilterInitStructure.CAN_FilterMaskIdLow=0x0000;
 CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0;
 CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;
 CAN_FilterInit(&CAN_FilterInitStructure);
//CAN_wrFilter (pos_ID);
 /* CAN FIFO0 message pending interrupt enable */ 
 CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);
//CAN_Receive(CAN1, &FIFO0, &RxMessage);
 /* disable interrupt handling */
 //CAN_ITConfig(CAN1, CAN_IT_FMP0, DISABLE);
 return (TestStatus)ret;
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Any suggestions?

Thank you very much.

Daniel Prieto

#can #transmit-issue #mailbox #can-bus
0 REPLIES 0