Example program provided by Embedded Systems Academy, Copyright 2000 Visit www.esacademy.com/faq/progs for more examples This example: CAN - name of application: can.c ==================================================== Demonstration of using the XA-C3 CAN Controller. The Self-test feature is used so only one development board is required. Hardware requirements ===================== Phytec RDK XAC3 with Philips XAC3 Software requirements ===================== Phytec Flash Tools www.phytec.com Raisonance XA compiler system - EVAL version sufficient www.raisonance.com Optional: Development Assistant-C by RistanCASE www.ristancase.ch Application description ============================================= Demonstrates the use of the CAN Controller for transmitting and receiving. Transmits a standard format message with ID 100H every time a switch is pressed or released, the data byte corresponding to the switch state. 00H = no switches pressed, 01H = switch S1 pressed, 02H = switch S2 pressed, 03H = both switches S1 and S2 pressed Messages received with the message ID 100H turn on or off LEDs D1 and D2 depending on the data byte. 00H = both LEDs off, 01H = only LED D1 on, 02H = only LED D2 on, 03H = both LEDs D1 and D2 on. The self test mode is enabled, so pressing the switches lights the LEDs. Uses a CAN bus speed of 125kbps, with CIA settings. Modifications: To enable the CAN controller without self test mode change the line: CANCMR = 0x40; to: CANCMR = 0x00; To change the transmitted message ID to 101H change the line: msg_object_reg[0].MIDH = 0x100 << 5; to: msg_object_reg[0].MIDH = 0x101 << 5; To allow messages with ID in the range 100H -> 107H change the line: msg_object_reg[1].MSKH = 0x001f; to: msg_object_reg[1].MSKH = 0x00ff; To transmit 2 bytes change the line: msg_object_reg[0].MSKH = 0x0001; to: msg_object_reg[0].MSKH = 0x0002; and store the additional byte in tx_buffer[1] Data Space Memory Map: 011010H - 01101FH -> receive buffer 011000H - 01100FH -> transmit buffer 010000H - 010FFFH -> Memory Mapped Registers 000000H - 0003FFH -> application variables and stack