2014-07-04 07:03 AM
Hi;
I am using STM32FCubeMX with its default configuration for the STRM32F4DISCOVERY board. I have enabled CAN1 master Mode (Loopback) and generated the Code for ''MDK-ARM 4.73. When i run the code the CAN initialisation fails in: HAL_CAN_Init(CAN_HandleTypeDef* hcan); Line 298 ..... .... .. /* Request leave initialisation */ hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_INRQ; /* Get tick */ tickstart = HAL_GetTick(); /* Wait the acknowledge */ while((hcan->Instance->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) { if((HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE) { hcan->State= HAL_CAN_STATE_TIMEOUT; /* Process unlocked */ __HAL_UNLOCK(hcan); return HAL_TIMEOUT; // ; Line 298 } } ............ ........... the funtion returns always HAL_TIMEOUT. What must i do to get the CAN-BUS Initialisation running? Thanks2014-07-08 04:03 AM
I have found the problem. The Initialisation failes without CAN-Driver hardware . It fails also in Loopback mode.
2014-12-20 07:53 PM
Thank you,I am the same situation as you,I have two discovery boards,But they are different, One of them failed because HAL_CAN_STATE_TIMEOUT,but another work well.So I check the Circuit diagram and I found that I should change the GPIO to PB8&PB9(The Circuit diagram Use those GPIOs),then the board works well.But CAN1 was in CAN_MODE_LOOPBACK mode,I guess this mode have relationship with hardware.
2015-05-28 07:14 AM
To fool the controller if you have no transceiver attached (just for a CAN_MODE_SILENT_LOOPBACK mode) you can just put the RX pin in pullup, this is the recessive state and the controller finds the line in a not busy state.
I used it to test some code with a discovery board and it works2017-05-04 01:25 AM
Hi All,
i am using STM32F303RE my code also stuck at this function :-
while((hcan->Instance->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)
{if((HAL_GetTick()-tickstart) > CAN_TIMEOUT_VALUE){hcan->State= HAL_CAN_STATE_TIMEOUT;/* Process unlocked */__HAL_UNLOCK(hcan);return HAL_TIMEOUT;}}i am using default code with certain pin changes (PIN are correct i crosscheck ) and my rx pin configuration are mention below :-
/* CAN1 RX GPIO pin configuration */
GPIO_InitStruct.Pin = CANx_RX_PIN; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = CANx_RX_AF;Please help, i will have to deliver this with in 2 day.
Thank's
Ankit Rathore