CAN overflow not reset?
Posted: Sat Mar 12, 2016 11:34 am
I've got an issue with error handling on CAN receives. If I end up with an overflow error, the only way to fix things is to re-power the STM32. I presume a software reset would work but haven't tried it yet.
I note the following very old thread viewtopic.php?f=16&t=1361&hilit=overflow+can but that's a throughput issue whereas the one I'm having is that the overflow flag is not reset.
Looking at the driver code the error is flagged as one would expect here:
Looking at the data sheet it's clear that the overflow flag is only reset by software, but the only place I can see that happening is in can_lld_receive. It does not appear to be done by stopping/starting the CAN peripheral. In my case that's what I do when I get errors.
As a suggestion, when stopping the peripheral would it not be better to use the software reset bit in the MCR? At the moment the code resets the MCR to its power-on default of 0x00010002 whereas a setting of 0x0008000 would cause a 'proper' reset of CAN and that would automatically return the MCR to 0x00010002 as well as all the other CAN registers to default.
I have done this 'hack' on my version of ChibiOS to try it but as the fault I'm seeing can take days or even weeks to appear it's not going to be a quick confirmation that this is the fix.
Anyone else seen this?
I note the following very old thread viewtopic.php?f=16&t=1361&hilit=overflow+can but that's a throughput issue whereas the one I'm having is that the overflow flag is not reset.
Looking at the driver code the error is flagged as one would expect here:
Code: Select all
canp->can->RF0R = CAN_RF0R_FOVR0;
osalSysLockFromISR();
osalEventBroadcastFlagsI(&canp->error_event, CAN_OVERFLOW_ERROR);
osalSysUnlockFromISR();Looking at the data sheet it's clear that the overflow flag is only reset by software, but the only place I can see that happening is in can_lld_receive. It does not appear to be done by stopping/starting the CAN peripheral. In my case that's what I do when I get errors.
As a suggestion, when stopping the peripheral would it not be better to use the software reset bit in the MCR? At the moment the code resets the MCR to its power-on default of 0x00010002 whereas a setting of 0x0008000 would cause a 'proper' reset of CAN and that would automatically return the MCR to 0x00010002 as well as all the other CAN registers to default.
I have done this 'hack' on my version of ChibiOS to try it but as the fault I'm seeing can take days or even weeks to appear it's not going to be a quick confirmation that this is the fix.
Anyone else seen this?