Now I want to check if the 2 CAN buses work.
I am going to use the stm32f407.ino example from this repository : https://github.com/nopnop2002/Arduino-STM32-CAN
1/In the stm32f407.ino I add these lines (in the
"bool CANInit(BITRATE bitrate, int remap)" function) in order to match to the hardware :
if (remap == 4) {
// CAN1
RCC->AHB1ENR |= 0x2; // Enable GPIOB clock
CANSetGpio(GPIOB, 8); // Set PB8
CANSetGpio(GPIOB, 9); // Set PB9
// CAN2
RCC->AHB1ENR |= 0x2; // Enable GPIOB clock
CANSetGpio(GPIOB, 5); // Set PB5
CANSetGpio(GPIOB, 6); // Set PB6
}
2/In the setup add :
bool ret = CANInit(CAN_1000KBPS, 4);
If you want to send to CAN2:
//uint8_t send_ch = 1; //send to CAN1
uint8_t send_ch = 2; ////send to CAN2
Both CAN work : we have the bases !
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.