All Forums
 Microsoft Windows CE
 CE Drivers
 CE CAN driver: Message ID is always zero
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

akidder

1519 Posts

Posted - 11 Jun 2002 :  15:20:39  Show Profile  Email Poster
Q: I can read and send messages with extended message IDs, but standard message IDs are always zero. What's going on?

The message id is there, but it's just shifted. The Intel CAN chip left-justifies the shorter message id in the 32-bit id register. Here's the background and solution:

Extended mode message ids are 29 bits long; standard mode message ids are 11 bits. The CAN chip uses the most significant bits of the ID register for the shorter id. The ID used in the ADS demonstration application is only 12 bits long, six bits short of showing up as a standard mode message id.

Here's the solution for general applications: When sending a message id in standard mode, shift the 11-bit standard message id left by 18 bits. When reading the standard mode message id, shift it right by 18 bits.

As an example, the sample CAN client application from ADS uses the 12-bit ID 0xFED. We need to shorten it to 11 bits (0x7ED) to work for both standard and extended modes. In the client sample application, you could change the code as follows:
  if (StandardMode)
CanSetMOId(m_hCAN, MO7, 0x7ED<<18); // standard mode, message id=0x7ED
else
CanSetMOId(m_hCAN, MO7, 0x7ED); // extended mode, message id=0x7ED


To read the message id in standard mode, shift the message id right. Eg.
  ReadFile(*pCAN, data, 1, &dwBytesRead, NULL);
if (StandardMode)
Packet.Mid = Packet.Mid>>18;


-----------------------
Drew Kidder
ADS Technology Transfer
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.02 seconds. Snitz Forums 2000