2016-05-12 12:24 AM
2016-05-12 12:44 AM
Pasting in stock library code provides no insight into how you initialize the pins, clocks, etc from your own code, or call this or other library functions.
2016-05-12 01:07 PM
Yeah you are right!
The issue I see after debugging is that bit 0 of MSR register does not get reset by the hardware after software reset of bit 0 of the MCR register ( exiting initialization state). Any clue as to why the hardware does not reset INK ( bit 0 ) of the MSR?2016-05-12 01:36 PM
This is how I configured my CAN hardware:
void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan) { GPIO_InitTypeDef GPIO_InitStruct; /*##-1- Enable peripherals and GPIO Clocks #################################*/ /* CAN1 Periph clock enable */ CAN_CLK_ENABLE(); /* Enable GPIO clock ****************************************/ CAN_GPIO_CLK_ENABLE(); /*##-2- Configure peripheral GPIO ##########################################*/ /* CAN1 TX GPIO pin configuration */ GPIO_InitStruct.Pin = GPIO_Pin_CAN_RX; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = GPIO_AF0_CAN; HAL_GPIO_Init(CAN_TX_GPIO_PORT, &GPIO_InitStruct); /* CAN1 RX GPIO pin configuration */ GPIO_InitStruct.Pin = GPIO_Pin_CAN_RX; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = GPIO_AF0_CAN; HAL_GPIO_Init(CAN_RX_GPIO_PORT, &GPIO_InitStruct); /*##-3- Configure the NVIC #################################################*/ /* NVIC configuration for CAN1 Reception complete interrupt */ HAL_NVIC_SetPriority(CAN_RX_IRQn, 1, 0); HAL_NVIC_EnableIRQ(CAN_RX_IRQn); }2016-05-12 01:48 PM
Are you mixing SPL and HAL code?
2016-05-12 02:25 PM
2016-05-12 03:03 PM
Standard Peripheral Library
STM32F072B-Discovery_FW_V1.0.1\Libraries\STM32F0xx_StdPeriph_Driver\src\stm32f0xx_can.c2016-05-12 09:37 PM
I am just using the SPL, exactly from the link you stated below
2016-05-13 07:08 AM
Ok, but you've presented HAL code being used for initialization.
I would be concerned about mixing the include files from one to the other, as the library code often uses internal bit flags, and shift settings, and not explicitly the bits used is the registers.Present complete/concise worked examples of code if you expect others to review/replicate tests