AN2283 Freescale Semiconductor / Motorola, AN2283 Datasheet - Page 39

no-image

AN2283

Manufacturer Part Number
AN2283
Description
Scalable Controller Area Network (MSCAN)
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
@interrupt void Error_Interrupt(void){
if(crflg.RWRNIF == 1){
if(crflg.RERRIF == 1){
if(crflg.TWRNIF == 1){
if(crflg.TERRIF == 1){
error_value3 = CTXERR;
if(crflg.BOFFIF == 1){
} // End of Error Interrupt
MOTOROLA
if(crflg.RERRIF == 1){ CRFLG = 0x10;}//crflg.RERRIF = 1;}
crier.RERRIE = 1;
crier.RWRNIE = 0;
rx_warning = rx_warning + 1; // An example of additional code to keep track of receiver warning errors
}
if(crflg.RWRNIF == 1){CRFLG = 0x40;}//crflg.RWRNIF = 1;} // Clear the RWRNIF Flag in the CRFLG register
crier.RWRNIE = 1; // Set the RWRNIE bit in the CRIER register to enable Receiver Warning Interrupts
crier.RERRIE = 0; // Clear the RERRIE bit in the CRIER register
rx_error = rx_error + 1; // An example of additional code to keep track of receiver errors
}
if(crflg.TERRIF == 1){CRFLG = 0x08;}//crflg.TERRIF = 1;} // Clear the TERRIF Flag in the CRFLG register
crier.TERRIE = 1; // Set the TERRIE bit in the CRIER register to enable the Transmitter Error Interrupt
crier.TWRNIE = 0; // Clear the TWRNIE bit in the CRIER register
tx_warning
}
if(crflg.TWRNIF == 1){CRFLG = 0x20;}//crflg.TWRNIF = 1;} // Clear the TWRNIF Flag in the CRFLG register
crier.TWRNIE = 1; // Set the TWRNIE bit in the CRIER register to enable Transmitter Warning Interrupts
crier.TERRIE = 0; // Clear the TERRIE bit in the CRIER register
tx_error = tx_error + 1; // An example of additional code to keep track of transmitter errors
if(crflg.BOFFIF == 1){CRFLG = 0x04;}
}
crflg.BOFFIF = 1;
if(BOFFIF == 0){
}
NOTE:
if(crflg.TERRIF == 1){CRFLG = 0x08;}//crflg.TERRIF = 1;} // Clear the TERRIF Flag in the CRFLG register
cmcr0.SFTRES = 1; // Set the Soft Reset to reinitialize the CAN like in the beginning of the application
cmcr0.SFTRES = 0;
} //End of If Statement crflg.BOFFIF == 0
= tx_warning + 1; // An example of additional code to keep track of transmitter warning errors
initialize(); //Reinitialize the MSCAN12 as in the beginning of the code
Motorola Scalable Controller Area Network (MSCAN) Interrupts
// Set the RERRIE bit in the CRIER register to enable Receiver Error Interrupt
// Clear the RWRNIE bit in the CRIER register
// Try to clear the BOFFIF Flag in the CRFLG register
A separate polling routine can be used to determine when to re-enable the
TWRNIE bit.
An example of the error interrupt ISR in C-code from the five of the six sources
described above follows.
The error routine is contained in only one ISR code. As seen in the example
below, each of the interrupt sources is contained within one ISR.
1. Clear the Transmitter Warning Interrupt Flag (TWRNIF) by writing a 1 to
2. Read the TWRNIF bit in CRFLG.
Freescale Semiconductor, Inc.
For More Information On This Product,
it. (CRFLG utilizes the exclusive OR operation.)
a.
b.
If TWRNIF = 0, then REC < 96, so set the Transmitter Warning
Interrupt Enable (TWRNIE) bit in CRIER to re-enable the
Transmitter Warning Interrupt.
If TWRNIF = 1, then the node is still in the Transmitter Warning
State (REC >= 96).
Go to: www.freescale.com
// Clear the RERRIF Flag in the CRFLG register
Error Interrupts Overview
AN2283/D
39

Related parts for AN2283