Initializing the SJA1000 Do - Set RESET_REQUEST bit - Clear TEST_MODE bit - Write ACCEPTANCE CODE REGISTER - Write ACCEPTANCE MASK REGISTER - Write BUS TIMING REGISTER 0 - Write BUS TIMING REGISTER 1 - Write OUTPUT CONTROL REGISTER - Enable interrupt sources (bits 1..4 of CONTROL REGISTER) - Clear RESET_REQUEST bit End Interrupt processing of SJA1000 On interrupt do Copy INTERRUPT REGISTER into CPU memory (* Use only the copy to evaluate interrupt bits during processing *) If WAKE_UP_INTERRUPT=1 then If CPU state = "Asleep" then (* Bus activated by external activity *) Awake CPU and process CAN datas Else (* GOTO SLEEP command was not accepted by SJA1000 *) Perform adequate processing Endif Endif If TRANSMIT_INTERRUPT=1 then Next CAN message can be written in TRANSMIT BUFFER Set TRANSMIT_REQUEST bit If ABORT_TRANSMISSION command requested If TRANMISSION_COMPLETE_STATUS=1 then (* Last CAN message transmitted. ABORT TRANSMISSION command not processed *) Else (* Last CAN message transmission aborted. ABORT TRANSMISSION command processed *) Endif Endif Endif If RECEIVE_INTERRUPT=1 then Read RECEIVE BUFFER content and store it into CPU memory Set RELEASE RECEIVE BUFFER bit If OVERRUN_INTERRUPT=1 then (* Some CAN datas are lost ! *) Modify program to reduce processing time of CAN interrupts Set CLEAR OVERRUN bit Endif Endif If ERROR_INTERRUPT=1 then Read STATUS REGISTER If BUS_STATUS=1 ("on bus") then (* SJA1000 is again active on bus *) If ERROR_STATUS=0 then (* CAN bus is slightly disturbed *) Else (* CAN bus is highly disturbed *) Endif Else (* SJA1000 is disconnected from bus *) If bus connection is again needed Clear RESET_REQUEST bit (* SJA1000 waits for 128*11 recessive bits to reconnect *) Endif Endif Endif End 'Polling' processing of SJA1000 Do Copy STATUS REGISTER into CPU memory (* Use only the copy to evaluate status bits during processing *) If TRANSMIT_BUFFER_ACCESS=1 then Next CAN message can be written in TRANSMIT BUFFER Set TRANSMIT_REQUEST bit If ABORT_TRANSMISSION command requested If TRANMISSION_COMPLETE_STATUS=1 then (* Last CAN message transmitted. ABORT TRANSMISSION command not processed *) Else (* Last CAN message transmission aborted. ABORT TRANSMISSION command processed *) Endif Endif Endif If RECEIVE_BUFFER_STATUS=1 then Read RECEIVE BUFFER content and store it into CPU memory Set RELEASE RECEIVE BUFFER bit If OVERRUN_INTERRUPT=1 then (* Some CAN datas are lost ! *) Modify program to reduce processing time of CAN interrupts Set CLEAR OVERRUN bit Endif Endif If BUS_STATUS=1 ("on bus") then (* SJA1000 is again active on bus *) If ERROR_STATUS=0 then (* CAN bus is slightly disturbed *) Else (* CAN bus is highly disturbed *) Endif Else (* SJA1000 is disconnected from bus *) If bus connection is again needed Clear RESET_REQUEST bit (* SJA1000 waits for 128*11 recessive bits to reconnect *) Endif Endif End