2016-08-24 09:53 PM
Hi Guys,
I tested CAN1(GPIOA_11 and 12) on Nucleo-F446RE with std lib 1.7 and successfully run Tx/Rx on 500Kbps and 250kbps. but, it is strange that 1Mbps is not working.Please review my setting below and let me know if there is something wrong. if(bRate == CAN_1Mbps) //not working { CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; CAN_InitStructure.CAN_BS1 = CAN_BS1_1tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq; CAN_InitStructure.CAN_Prescaler = 9; }else if(bRate == CAN_500Kbps ){ //working CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; CAN_InitStructure.CAN_BS1 = CAN_BS1_2tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq; CAN_InitStructure.CAN_Prescaler = 15; }else if(bRate == CAN_250Kbps ) { //working CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; CAN_InitStructure.CAN_BS1 = CAN_BS1_2tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq; CAN_InitStructure.CAN_Prescaler = 30; }here is my clock configuration..*============================================================================= * Supported STM32F446xx devices *----------------------------------------------------------------------------- * System Clock source | PLL (HSE) *----------------------------------------------------------------------------- * SYSCLK(Hz) | 180000000 *----------------------------------------------------------------------------- * HCLK(Hz) | 180000000 *----------------------------------------------------------------------------- * AHB Prescaler | 1 *----------------------------------------------------------------------------- * APB1 Prescaler | 4 *----------------------------------------------------------------------------- * APB2 Prescaler | 2 *----------------------------------------------------------------------------- * HSE Frequency(Hz) | 8000000 *----------------------------------------------------------------------------- * PLL_M | 8 *----------------------------------------------------------------------------- * PLL_N | 360 *----------------------------------------------------------------------------- * PLL_P | 2 *----------------------------------------------------------------------------- * PLL_Q | 7 *-----------------------------------------------------------------------------thanks.. #f446 #can2016-08-25 09:46 AM
Define the test conditions/criterion for ''not working''
2016-08-29 12:38 AM
Hi,
I'm using ''Microchip CAN bus analyzer'' connecting to CANH,L of TJA1050 connecting to CAN1_RX/TX of F446RE.
this is my full code for CAN1 config..
void CAN_Config(CAN_BAUDRATE bRate, uint32_t TxId, uint32_t RxId)
{ GPIO_InitTypeDef GPIO_InitStructure;TxStdId = TxId;
RxStdId = RxId;#ifdef RX_TEST
/* NVIC configuration */ NVIC_Config(); #endif/* CAN GPIOs configuration **************************************************/
/* Enable GPIO clock */
RCC_AHB1PeriphClockCmd(CAN_GPIO_CLK, ENABLE);/* Connect CAN pins to AF9 */
GPIO_PinAFConfig(CAN_GPIO_PORT, CAN_RX_SOURCE, CAN_AF_PORT); GPIO_PinAFConfig(CAN_GPIO_PORT, CAN_TX_SOURCE, CAN_AF_PORT);/* Configure CAN RX and TX pins */
GPIO_InitStructure.GPIO_Pin = CAN_RX_PIN | CAN_TX_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(CAN_GPIO_PORT, &GPIO_InitStructure);/* CAN configuration ********************************************************/
/* Enable CAN clock */ RCC_APB1PeriphClockCmd(CAN_CLK, ENABLE);/* CAN register init */
CAN_DeInit(CANx);/* 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 Baudrate = 1 MBps (CAN clocked at 30 MHz) */ if(bRate == CAN_1Mbps) //not working { CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; CAN_InitStructure.CAN_BS1 = CAN_BS1_1tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq; CAN_InitStructure.CAN_Prescaler = 9; }else if(bRate == CAN_500Kbps ){ //working CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; CAN_InitStructure.CAN_BS1 = CAN_BS1_2tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq; CAN_InitStructure.CAN_Prescaler = 15; }else if(bRate == CAN_250Kbps ) { //working CAN_InitStructure.CAN_SJW = CAN_SJW_1tq; CAN_InitStructure.CAN_BS1 = CAN_BS1_2tq; CAN_InitStructure.CAN_BS2 = CAN_BS2_3tq; CAN_InitStructure.CAN_Prescaler = 30; }CAN_Init(CANx, &CAN_InitStructure);
}