Hello,
can anybody provide me more details about the CAN_ES register and related interrupts ?
The sentence in Technical Reference Manual is
"This register indicates error conditions, if any, of the CAN module. Interrupts are generated by PER, BOff
and EWarn bits (if EIE bit in CAN Control Register is set) and by RxOk, TxOk, and LEC bits (if SIE bit in
CAN Control Register is set)."
Does it mean that an interrupt is generated on any change (0 to 1 and 1 to 0) of EWarn, BOff, PER ?
Let's take the following example:
enabled CAN_INT_IE0 and CAN_INT_ERROR (not CAN_INT_STATUS).
When an internal Error counter overcomes 96, I expect EWarn = 1 and an interrupt triggered.
Inside the interrupt function I read the CAN_ES register (clearing the EWarn flag).
If at next transmission or reception the counter is still bigger than 96, EWarn will be set again to 1 and another interrupt will be triggered ?
What happens when a counter overcomes 127 ?
I guess EPass is set to 1 (but without interrupt). What about EWarn ? Is it going still to be set to 1 (since the counter is > 96) ?
Are the flags independent each other, or the most important inhibits the others (BOff inhibits EPass and EWarn) ?
Finally, it seems to me that the only way to catch the Error Active condition is to enable also CAN_INT_STATUS and check under interrupt the following condition
((RxOk = 1) or (TxOk = 1)) and ((BOff or EWarn or EPass) = 0)
Is it right or it is enough the transition 1 to 0 of EWarn to trigger an interrupt ?
Thank you in advance.