Getting bizzarre CAN IDs when using STR73x library
Company  
ST Home | Microcontrollers

Index  »  CAN  »  Getting bizzarre CAN IDs when using STR73x library
     
   Getting bizzarre CAN IDs when using STR73x library
 Moderated by :   »  Jatin

Author
beginning argument    ( Replies received: 2 )
mcu_guy   Posted 24-04-2008 at 22:59   



Registered on :
04-24-2009

Messages : 4

 OFF-Line

We've just recently switched to the STR731FV2 processor and are attempting to utilize the STR73x library to send CAN messages. We tried the example CAN code and discovered that the identifer portion of our CAN messages were not the same as the identifer we had in our code. It looks like either the library or the processor is doing some sort of reverse endian / bit masking operation on the identifier. Any insight would be appreciated.

Thanks. :)



 Profile   Quote  
mcu_guy   Posted 29-04-2008 at 17:01   



Registered on :
04-24-2009

Messages : 4

 OFF-Line

Here is an example of what I am seeing:

I am sending an can fram with an extended id. The identifier I have coded is 0x00000001. The identifier of the can message being sent is 0x00040000.

Any insight would be helpful.



 Profile   Quote  
wolfgang.hill   Posted 07-05-2008 at 04:01   



Registered on :
04-21-2009

Messages : 3

 OFF-Line

We are no longer using the STR73x (we have gone with the STM32 instead), but I had the same problem. I only discovered it when connecting to other micros ('cos 2 STR73x's will play nicely together as they both have the same error!).

I have a modified 73x_can.c that should hopefully fix your problem, but I can't seem to attach it. So here are the changes I made (marked with "WLF:" comments). The old code is still there but commented out.

//#define EXT_RANGE_ID_MSK_L(range_start, range_end) ((u16)(RANGE_ID_MSK((range_start), (range_end)) >> 11))
//#define EXT_RANGE_ID_MSK_H(range_start, range_end) ((u16)(STD_RANGE_ID_MSK((range_start), (range_end)) | ((RANGE_ID_MSK((range_start), (range_end)) >> 27) & 0x03)))
//#define EXT_RANGE_ID_ARB_L(range_start, range_end) ((u16)(RANGE_ID_ARB((range_start), (range_end)) >> 11))
//#define EXT_RANGE_ID_ARB_H(range_start, range_end) ((u16)(STD_RANGE_ID_ARB((range_start), (range_end)) | ((RANGE_ID_ARB((range_start), (range_end)) >> 27) & 0x03)))
//
//#define EXT_FIXED_ID_MSK_L(id) ((u16)(FIXED_ID_MSK(id) >> 11))
//#define EXT_FIXED_ID_MSK_H(id) ((u16)(STD_FIXED_ID_MSK(id) | ((FIXED_ID_MSK(id) >> 27) & 0x03)))
//#define EXT_FIXED_ID_ARB_L(id) ((u16)(FIXED_ID_ARB(id) >> 11))
//#define EXT_FIXED_ID_ARB_H(id) ((u16)(STD_FIXED_ID_ARB(id) | ((FIXED_ID_ARB(id) >> 27) & 0x03)))
//WLF:
#define EXT_RANGE_ID_MSK_L(range_start, range_end) ((u16)(RANGE_ID_MSK((range_start), (range_end)) & 0x0000FFFF))
#define EXT_RANGE_ID_MSK_H(range_start, range_end) ((u16)((RANGE_ID_MSK((range_start), (range_end)) >> 16) & 0x00001FFF))
#define EXT_RANGE_ID_ARB_L(range_start, range_end) ((u16)(RANGE_ID_ARB((range_start), (range_end)) & 0x0000FFFF))
#define EXT_RANGE_ID_ARB_H(range_start, range_end) ((u16)((RANGE_ID_ARB((range_start), (range_end)) >> 16) & 0x00001FFF))

#define EXT_FIXED_ID_MSK_L(id) ((u16)(FIXED_ID_MSK(id) & 0x0000FFFF))
#define EXT_FIXED_ID_MSK_H(id) ((u16)((FIXED_ID_MSK(id) >> 16) & 0x00001FFF))
#define EXT_FIXED_ID_ARB_L(id) ((u16)(FIXED_ID_ARB(id) & 0x0000FFFF))
#define EXT_FIXED_ID_ARB_H(id) ((u16)((FIXED_ID_ARB(id) >> 16) & 0x00001FFF))
//WLF:END


And in the CAN_ReceiveMessage() function...

else
{
/* extended ID*/
pCanMsg->IdType = CAN_EXT_ID;
// tmpId0 = ((u32)CANx->sMsgObj[1].A1R << 11);
// tmpId1 = (((u32)CANx->sMsgObj[1].A2R & 0x0003) << 27);
// pCanMsg->Id = ((CANx->sMsgObj[1].A2R >> 2) & 0x07FF) | tmpId0 |tmpId1 ;
//WLF:
pCanMsg->Id = (u32)(CANx->sMsgObj[1].A2R & 0x1FFF);
pCanMsg->Id <<= 16;
pCanMsg->Id |= (u32)(CANx->sMsgObj[1].A1R);
//WLF:END
}


Good Luck!

If you can't decipher this, let me know your e-mail and I'll send you the complete file.

Cheers,

Wolf



 Profile   Quote  
On Top

Search in the forums
 
Jump To