I am developing a CAN-driver for my AT90CAN128 driven project.
Right now, I am facing problems handling CAN-error-interrupts.
The testing environment is simply unplugging all CAN-nodes, then trying to send a CAN-Message.
After sending, I get an interrupt from the CAN-engine which is correct.
At first, CANGIT contains 0xA0 (CANIT & OVRTIM)
I don't want OVRTIM-interrupts, so I didn't set the according flag, but obviously the OVRTIM-flag is set even with no interrupt.
CANIt is read-only, so I don't have to handle it.
I wonder, that AERG is NOT set in this situation ( see below)
In CANGIE all bits are set, except for ENBX and ENOVRT.
CANTEC is 0x86 and stays there, meaning it does not count any higher.
Remember - the CAN message is blown into space, because all bus members are unplugged.
CANSTMOB contains 0x01 after setting CANPAGE to the MOb which triggered the interrupt.
So this means "Acknowledgement error", which must be result of unplugging the other nodes, meaning that noone received the message.
Q1: will always only ONE bit be set in CANSTMOB ? e.g. TXOK or RXOK or one of the error bits or can there be a combination ?
Q2: I am facing AERR, but why only in the according MOb, but not as an general error ? (see above)
Q3: The datasheet says something "• Bit 0 – AERR: Acknowledgment Error
This flag can generate an interrupt. It must be cleared using a read-modify-write software routine
on the whole CANSTMOB register."
I do a "CANSTMOB=0" which does not change the status of AERR.
So I get the interrupt again and again until I replug a CAN-node; then the AERR disappears without any manipulation.
How must I do a "read-modify-write" ?
Thank you for your help