2015-12-23 01:57 AM
Hello!
I am working on STM32 board and I am able to make it work by hitting transmit and receive handlers on CAN loopback mode but not normal mode. Are there any additional settings that have to be changed for CAN normal compared to loopback? Thank you! #stm2015-12-23 04:56 AM
Are there any additional settings that have to be changed for CAN normal compared to loopback?
There has to be a receiving device on the bus to acknowledge the transmission.
2015-12-23 05:59 PM
Hello Clive,
I have already connected the board to a controller, which would be the receiving device of the transmitted message from the board.2015-12-23 09:31 PM
Ok, there is very little detail here to work with.
You'll need to double check the bit rates are the same, and the transceivers and connectivity. What STM32 is being used here? Custom board? Describe/diagram the circuit. What speeds / pins are you configuring? Show code2015-12-28 01:17 AM
Hi Clive,
I am a custom made board using STM32F302 MCU and pinout. I have configured the rx and tx pins as below:GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF9_CAN; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* CAN1 RX GPIO pin configuration */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF9_CAN; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);/* System interrupt init*/
HAL_NVIC_SetPriority(USB_HP_CAN_TX_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USB_HP_CAN_TX_IRQn); // HAL_NVIC_SetPriority(CAN_SCE_IRQn, 0, 0); HAL_NVIC_SetPriority(CAN_SCE_IRQn, 1, 0); HAL_NVIC_EnableIRQ(CAN_SCE_IRQn); HAL_NVIC_SetPriority(USB_LP_CAN_RX0_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USB_LP_CAN_RX0_IRQn); I tried changing NART to ENABLE under CAN settings and I am able to hit Transmit handler (USB_HP_CAN_TX) but I am getting ACK error under HAL_CAN_IRQHANDLER function.2015-12-28 06:19 AM
Ok, so you'll probably want to focus on the connectivity and data rates. If you have two of your boards, try setting one up as a listener, and the other as a sender.
2015-12-29 12:58 AM
Hello Clive,
I tried to set up two boards such that one board transmits the message and the error receives the message. I downloaded the same firmware onto both boards. However, I am still getting ACK error.2015-12-29 01:26 AM
Look at the ESR register, it will tell you the actual error. Are you using twisted pair wiring, and do you have a 60 ohm termination resistor at each end?
2015-12-29 06:10 PM
Hi peacock.jack.003,
Yes, there is a 120 ohm termination register used on both modules and they are connected using twisted pair wiring. I have checked the ESR register and I am getting a LEC for acknowledgement error.