LPC11C24 CAN explanation: explain like I'm five

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC11C24 CAN explanation: explain like I'm five

1,553 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by andreibuiza on Mon Nov 03 20:59:24 MST 2014
Hello all,

I've been spending a lot of time trying to figure out how to use CAN. All I need to do is some basic transmit and receive functions but the documentation/sample code under LPCopen and LPC11C24 user guide is very hard to read. Note that I have never used CAN before, all I know is its general overview from Wikipedia.  I attached a snippet from the user manual which I think contains some info, and I also attached the LPCopen CAN code snippet.

Basically I'm confused on how to setup msg_obj, I already figured how to use the CAN functions, ie. LPC_CCAN_API->can_transmit and LPC_CCAN_API->config_rxmsgobj.

My questions are:
what to do with msg_obj.msgobj?
what to do with msg_obj.mode_id?
what to do with msg_obj.mask?

Any form of guidance is deeply appreciated :)

MrBuggy.
Labels (1)
0 Kudos
5 Replies

688 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 1234567890 on Mon Nov 10 09:51:47 MST 2014
Enjoy http://www.lpcware.com/content/forum/lpc11c24-send-and-receive-an-extended-frame
0 Kudos

688 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by andreibuiza on Tue Nov 04 23:02:54 MST 2014
Can you give an example for mask? I somewhat get your explanation but an example showing a transmitter node and a receiver node in a CAN network would help me very much! Thank youU!
0 Kudos

688 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 1234567890 on Tue Nov 04 14:36:50 MST 2014
Indeed the UM could be a bit more precise in explanation. In another thread I 'adviced' to extend the example call on top of page 323 in UM10398 (Rev 12.3) to make it very clear:

'original' example call should be:
// Configure message object 1 to receive all 11-bit messages 0x000-0x00F
msg_obj.msgobj = 1;
msg_obj.mode_id = 0x000 | CAN_MSGOBJ_STD;
msg_obj.mask = 0x7F0;
(*rom)->pCAND-> config_rxmsgobj(&msg_obj);

If you replace
msg_obj.mode_id = 0x000 | CAN_MSGOBJ_EXT;
you use a 29-bit identifier instead.
In detail: 0x7F0 is binary 0111 1111 0000. That means, the LSB of the identifier (binary 0000) isn't evaluated when receiving a message. Just when all your bits in the mask with '1' match the received identifier, the message is valid. A '0' in the mask means that this bit isn't relevant for that comparison.
Cave: But when you extend the identifier from 11 to 29 bits, you have to extend the mask as well.
So the mask has to be extended from 11 bit 29 bit as well.
The 29 bit mask mustn't be 0x7F0. It must be...
Your homework.
0 Kudos

688 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by andreibuiza on Tue Nov 04 13:54:10 MST 2014
Hi I'm sorry but I do not understand the mode_id and mask. In the LPC OPEN example code I attached in the first post, I can't see how it says its for 11 bit or 29 bit. Can you give me an example with explanation please?

Thanks,
mrBuggy
0 Kudos

688 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 1234567890 on Tue Nov 04 04:26:22 MST 2014

Quote: andreibuiza

My questions are:
what to do with msg_obj.msgobj? => Number of the message object (1-32)
what to do with msg_obj.mode_id? => CAN-ID (11 or 29 bit)
what to do with msg_obj.mask? => Mask for CAN-ID (what bits from CAN-ID must match)
MrBuggy.


0 Kudos