Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 10 months ago.
Nucleo F103 infinite loop in can_frequency(can_t *obj, int f)
Can not use CAN with Nucleo F103 because CAN init fails when setting default CAN frequency.
#include "mbed.h" CAN can(PA_11, PA_12); int main() { while (true) { } }
Nucleo F103 can_api.c line 180 infinite loop. Method called by CAN's constructor.
Infinite loop in CAN frequency
int can_frequency(can_t *obj, int f) { int pclk = HAL_RCC_GetPCLK1Freq(); int btr = can_speed(pclk, (unsigned int)f, 1); CAN_TypeDef *can = (CAN_TypeDef *)(obj->can); if (btr > 0) { can->MCR |= CAN_MCR_INRQ ; while((can->MSR & CAN_MSR_INAK) != CAN_MSR_INAK) { } can->BTR = btr; can->MCR &= ~(uint32_t)CAN_MCR_INRQ; while((can->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) { } return 1; } else { return 0; } }