Hi all
I'm working on GIGA board with CAN but I have a strange problem on it. I know it's available the Arduino_CAN library but the methods exported are very few and I need the way to set a CAN packet filter that is not available on it. The solution I though was to directly allocate the orignal mbed CAN object like this:
mbed::CAN mycan(PIN_CAN0_TX, PIN_CAN0_RX);
However if I put this line in my firmware code the arduino giga stop working. It's seems the firmware crashes for some reasons and is also not possible to upload a new firmware unless set the update mode manually. I still haven't understood why this happens, someone has already experienced this problem and know a workaround?
Thank you
Hi @falsinsoft. For some reason the order of the arguments in the constructor of the Arduino_CAN library (TX, RX) is opposite to the order in the Mbed OS CAN class constructor (RX, TX):
https://os.mbed.com/docs/mbed-os/v6.16/mbed-os-api-doxy/classmbed_1_1_c_a_n.html#a48c6d4d6def0f93bde7c0c0ce554a6f4
CAN ( PinName rd,
PinName td
)
Creates a CAN interface connected to specific pins.
Parameters
|
|
rd |
read from transmitter |
td |
transmit to transmitter |
So you should change your code to this:
mbed::CAN mycan(PIN_CAN0_RX, PIN_CAN0_TX);
Hi @ptillisch, I realy thank you for your reply. Your suggestion solved the problem. However I am extremely surprised that simply reversing two pins can cause a total system crash. I would never have thought that the cause could be what you indicated.
Thanks again
You are welcome. I'm glad it is working now.
It is how Mbed OS is designed. If you do something that is clearly wrong, an exception is thrown. The idea is that this will be a more friendly behavior than it soldiering on silently with a program that is patently invalid as a bare metal system which doesn't have an exceptions capability might do.
Mbed OS prints debug information to the UART when an exception is thrown. In theory this can be used for troubleshooting. Unfortunately I think that the average Arduino user (many of whom don't even know what Mbed OS is) probably will find that they are not able to effectively interpret the debug information.
Thank you for the very interesting explanation. It's my bad I didn't note the debug infomation on UART because I use Visual Studio Code with plaftormio extension to work with Arduino and frequently forgot to activate the serial debug console after programming finished. Now that I know it I'll check better if some info will be printed in case of problems.
Thank you again
Please note that, by default the debug info is printed on the hardware UART connected to pins 0 and 1 on the board, not to the USB CDC serial port produced on the USB connection to your computer. So you must connect a USB to serial bridge module (AKA "FTDI") between pin 1 and your computer and check the data received on the bridge module's port.
The data is sent at 115200 baud. It is printed on startup, so you should press the RST button on the board after opening the bridge module's serial port in a terminal to see the output.
If you did that while the board was running the bugged sketch, you would see this in the serial terminal:
++ MbedOS Error Info ++
Error Status: 0x80010130 Code: 304 Module: 1
Error Message: pinmap not found for peripheral
Location: 0x8046BA7
Error Value: 0x1D
Current Thread: main Id: 0x24002B18 Entry: 0x8044469 StackSize: 0x8000 StackMem: 0x24003370 SP: 0x2400B28C
For more info, visit: https://mbed.com/s/error?error=0x80010130&osver=61700&core=0x411FC271&comp=2&ver=90200&tgt=GIGA
-- MbedOS Error Info --
And if you visit the supplied URL:
https://armmbed.github.io/mbedos-error/?error=0x80010130&osver=61700&core=0x411FC271&comp=2&ver=90200&tgt=GIGA
You will obtain the following additional information:
ERROR DECODER
0x80010130
TYPE:
System
MODULE
Platform
ERROR CODE
Pinmap Invalid
The pinmap provided is invalid. Use the "Location" reported to figure out the address of the location which caused the error or try building a non-release version with MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED configuration enabled to capture the filename and line number where this error originates from.
Thank you again for the expalnation, very very usefu and interesting. However pin 0 and 1 are accessible in the giga board? I'm checking the pinout here but I can not find the hw debug serial. Probably I didn't note...
Thank you
Absolutely. Right here:
You actually only need to make a connection to pin 1 since you are only reading the data transmitted by the board and don't have any need to send data back to the board over the UART.
@ptillisch Very sorry, just today I noted that I forgot to thank you for the very very very precious informations. Thank you again, you made my day and now I know how to discover some other "strange" future crash, just in case... 
You are welcome. I'm glad if I was able to be of assistance.
Regards,
Per