DESIGN OF A CUSTOM ASIC INCORPORATING CAN™ AND 1 ...

DESIGN OF A CUSTOM ASIC INCORPORATING CAN™ AND 1 ... DESIGN OF A CUSTOM ASIC INCORPORATING CAN™ AND 1 ...

acumen.lib.ua.edu
from acumen.lib.ua.edu More from this publisher
15.08.2013 Views

Error Handler Read ERRIF Register RxB1 Overflow? No Error Warning Flag Set? No Rx Error Passive Flag Set? No Tx Error Passive Flag Set? No Bus-Off Flag Set? No Send Error Message 0x3FF, Error Code = 0x13 Done Yes Yes Yes Yes Yes Yes Send Error Message 0x3FF, Error Code = 0x11 Rx Warning Flag Set? Yes Send Error Message 0x3FF, Error Code = 0x01 Send Error Message 0x3FF, Error Code = 0x03 Send Error Message 0x3FF, Error Code = 0x04 1 st Bus-Off Occurrence? Yes Set Bus-Off Flag and Re-Initialize MCP2515 Send Error Message 0x3FF, Error Code = 0x12 Message Transmitted Successfully Send Error Message 0x3FF, Error Code = 0x02 Figure 5.38 Error Handler Routine Flowchart [47]. 179 No No No Enter Idle State; MCU must Reset System Node

When a valid message is received, the FILHIT bits of the RXB1CTRL register are read to determine which message has been received. Depending on the filter match number, they are described as follows: Filter 1The PIC® MCU initiates an A/D conversion on AN1, waits for the conversion to complete, loads the ADRES register value into the MCP2515 Transmit Buffer 0 and Data Byte 0, and sends the RTS command. Filter 2The PIC® MCU reads the TXRTSCTRL register for the value of the three input pins, loads this value into the MCP2515 transmit buffer and sends the RTS command. Filter 3 or 4The PIC® MCU reads the first byte of the received message and writes it to the appropriate output pin via the MCP2515 BFPCTRL register. Filter 5The PIC® MCU reads the first byte of the received message and stores the new units address into the EEDATA register and write the new unit address into the EEPROM. Filter 6The PIC® MCU turns off Digital Outputs 1 and 2. The system also provides for error detection for a number of different types of errors that may occur, including CAN bus errors detected by the MCP2515, as well as invalid system state errors (See Figure 5.38). When any of these errors are detected, the system transmits a message with the ID of 0x3FF. This message contains one data byte which is a code used to represent the type of error that occurred. The one exception to this is the Bus-Off condition that the MCP2515 may enter if a large number of transmit errors are detected. If the Bus-Off 180

Error Handler<br />

Read ERRIF Register<br />

RxB1 Overflow?<br />

No<br />

Error Warning<br />

Flag Set?<br />

No<br />

Rx Error<br />

Passive Flag<br />

Set?<br />

No<br />

Tx Error<br />

Passive Flag<br />

Set?<br />

No<br />

Bus-Off Flag<br />

Set?<br />

No<br />

Send Error Message<br />

0x3FF, Error Code =<br />

0x13<br />

Done<br />

Yes<br />

Yes<br />

Yes<br />

Yes<br />

Yes<br />

Yes<br />

Send Error Message<br />

0x3FF, Error Code =<br />

0x11<br />

Rx Warning<br />

Flag Set?<br />

Yes<br />

Send Error Message<br />

0x3FF, Error Code =<br />

0x01<br />

Send Error Message<br />

0x3FF, Error Code =<br />

0x03<br />

Send Error Message<br />

0x3FF, Error Code =<br />

0x04<br />

1 st Bus-Off<br />

Occurrence?<br />

Yes<br />

Set Bus-Off Flag and<br />

Re-Initialize<br />

MCP2515<br />

Send Error Message<br />

0x3FF, Error Code =<br />

0x12<br />

Message<br />

Transmitted<br />

Successfully<br />

Send Error Message<br />

0x3FF, Error Code =<br />

0x02<br />

Figure 5.38 Error Handler Routine Flowchart [47].<br />

179<br />

No<br />

No<br />

No<br />

Enter Idle State;<br />

MCU must Reset<br />

System Node

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!