??? 01/13/08 22:15 Read: times |
#149409 - SiLabs f040 CAN Addressing? |
Hi all, I am trying to figure out the example code provided with the SiLabs CAN1 and CAN2 example code, in particular the addressing between the two boards.
I have read all the data sheets and the Bosch C_CAN user manual to try and figure this out. in short from what I can understand you set an IDENTIFIER field somewhere (assumed to be IF1ARB1) and this describes the message type. you then set filtering at the receiving end to filter out the messages you want or don't want based on the IDENTIFIER. For example We have 6 devices all with a unique identifier 000101 - Window 1 000110 - Window 2 000111 - Window 3 000100 - Window 4 001001 - Front Wipers 001010 - Rear Wipers now based on this if I wanted to send a message to all the windows, (for example to wind them up when the ignition is turned off) I should be able to set an acceptance mask of 000111 and what ever data followed would be carried out by all windows Alternatively if I wanted to address only window 1. I would set the mask as 000101 I can't figure out how this is done in the example code below. and changing the IF1ARB1 data from 0x8004 to anything else seems to make little difference. I may well have the wrong end of the stick here, so feel free to correct me if I am way off beam. Any help in this addressing is greatly appreciated. Regards Marshall Brown //Initialize Message Object for RX void init_msg_object_RX (char MsgNum) { SFRPAGE = CAN0_PAGE; CAN0ADR = IF1CMDMSK; // Point to Command Mask 1 CAN0DAT = 0x00B8; // Set to WRITE, and alter all Msg Obj except ID MASK // and data bits CAN0ADR = IF1ARB1; // Point to arbitration1 register CAN0DAT = 0x0000; // Set arbitration1 ID to "0" CAN0DAT = 0x8004; // Arb2 high byte:Set MsgVal bit, no extended ID, // Dir = RECEIVE CAN0DAT = 0x0480; // Msg Cntrl: set RXIE, remote frame function disabled CAN0ADR = IF1CMDRQST; // Point to Command Request reg. CAN0DATL = MsgNum; // Select Msg Obj passed into function parameter list // --initiates write to Msg Obj // 3-6 CAN clock cycles to move IF register contents to the Msg Obj in CAN RAM } //Initialize Message Object for TX void init_msg_object_TX (char MsgNum) { SFRPAGE = CAN0_PAGE; CAN0ADR = IF1CMDMSK; // Point to Command Mask 1 CAN0DAT = 0x00B2; // Set to WRITE, & alter all Msg Obj except ID MASK bits CAN0ADR = IF1ARB1; // Point to arbitration1 register CAN0DAT = 0x0000; // Set arbitration1 ID to highest priority CAN0DAT = 0xA000; // Autoincrement to Arb2 high byte: // Set MsgVal bit, no extended ID, Dir = WRITE CAN0DAT = 0x0081; // Msg Cntrl: DLC = 1, remote frame function not enabled CAN0ADR = IF1CMDRQST; // Point to Command Request reg. CAN0DAT = MsgNum; // Select Msg Obj passed into function parameter list // --initiates write to Msg Obj // 3-6 CAN clock cycles to move IF reg contents to the Msg Obj in CAN RAM. } |
Topic | Author | Date |
SiLabs f040 CAN Addressing? | 01/01/70 00:00 | |
All Source Code | 01/01/70 00:00 | |
Figured it out! | 01/01/70 00:00 | |
Help me for serial port Baud rate: | 01/01/70 00:00 | |
why hijack a thread?![]() | 01/01/70 00:00 |