We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, i am using the AT89C51CC01 controller with integrated can and the can driver supplied together with the Keil App Note 167 Problem: Sending and receiving messages with extended IDs works ok, in simulated and real, but i have to switch to standard identifiers with 11 bit message length and so I modified some parts of the can_drv.c The simulator shows me, that my device is sending standard messages, but i have a problem with incoming messages and would like to simulate them using the SendInfo command in the debugger.ini How do I tell the SendInfo command only to use standard identifiers? - because the Simulator shows me that SendInfo is using extended identifiers
/* * Send Information on any ID */ FUNC void SendInfo (unsigned long id, // message ID unsigned char len, // message length unsigned char val) { // 1. value byte CAN0ID = id; // Set VTREG that keeps next ID CAN0L = len; // Set VTREG with message length CAN0B0 = val; // Set the data registers // CAN0B1 = val+1; // CAN0B2 = val+2; // CAN0B3 = val+3; // CAN0B4 = val+4; // CAN0B5 = val+5; // CAN0B6 = val+6; // CAN0B7 = val+7; CAN0IN = 2; // Send message to simulated controller }
The trick is in what value you assign to the CAN-IN VTREG. The CAN0IN VTREG specifies the type of CAN message the simulated MCU will receive. The values 1-4 are used: 1: Message with 11-bit ID. 2: Message with 29-bit ID. 3: Message Request with 11-bit ID. 4: Message Request with 29-bit ID. So, CAN0IN = 1; should make the simulated MCU receive an 11-bit message ID. Jon
Change CAN0IN=2 to CAN0IN=1 to simulate incoming messages with 11-bit identifiers. See App Note 147 for details of the meaning of all these CAN... virtual registers. Furthermore, what is the common way of receiving can messages with different lengths and ids, if there are not enough messagebuffers free for each type? - Configuring one messageobject with a weak filter and accept the canerror about the length? What makes you think you would get CAN errors about the length of incoming messages? I don't know the CAN controller implementation you're using, but I'd be very surprised if it even looked at the length setting for a message center on receiving a message, or if it does, you couldn't turn off such a "feature".
Hi, Configuring one messageobject with a weak filter and accept the canerror about the length? CAN macro of CC01 does not generate Error if Data Lenght not match. Anyway if such condition occures then it sets Data Lenght Code Warning bit in CANSTCH register. As result, it can not generate error interrupt but may be checked with your software. So you may set DLC of an object for reception to any value; after message has actualy been received DLC of CANCONCH will be updated by the received DLC and it sets Warning bit DLCW if no match. Good days!
Hello, thanks to all especially John for the good answers. It is working now. Greetings Axel