Description
Description
- Type: Bug
- Priority: Blocker
Bug
Target
nucleo_f767zi
Toolchain:
GCC_ARM
mbed-cli version:
1.0.0
meed-os sha:
bcf7085
Expected behavior
STM32F767ZI CAN objects can be instantiated regardless of CAN bus usage.
Actual behavior
CAN objects will be instantiated if the CAN bus is not currently in use. However, if there is another node on the CAN bus that is broadcasting at the time of instantiation, then the CAN bus instantiation hangs until the bus is no longer in use.
Steps to reproduce
To reproduce, have a node broadcast on a CAN bus shared with the STM32F767ZI (I did this at roughly 100ms intervals for my application). Try instantiating a CAN object using the pins connected to the bus. The instantiation should hang until the other node stops broadcasting or is disconnected from the bus, and then the code should continue executing per usual. If there is no CAN bus traffic, then there shouldn't be an issue (this was tested with the LPC1768 and produced the expected behaviour).
Below is a simpler version of the code I used to test this:
#include "mbed.h"
Ticker ticker;
DigitalOut led1(LED1);
DigitalOut led2(LED2);
CAN* can2_ptr;//(PD_0, PD_1);
Serial pc(USBTX,USBRX);
int main()
{
pc.baud(115200);
pc.printf("main()\r\n");
//CAN can2(p9, p10); //for LPC1768
CAN can2(PD_0, PD_1); //for STM32F767ZI
pc.printf("created can\r\n");
can2_ptr = &can2;
can2.frequency(500000);
pc.printf("set frequency \r\n");
CANMessage msg;
while(1) {
if(can2.read(msg)) {
pc.printf("<-*******Message received:id=%x,data=",msg.id);
for(int i=0; i<8; i++) {
pc.printf("%x,",msg.data[i] );
}
pc.printf("\n\r");
led2 = !led2;
}
}
}
This code should not print the "created CAN" line.