C_CAN SDO Message handling - Solved

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

C_CAN SDO Message handling - Solved

904 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gwlindberg on Wed Sep 30 15:52:22 MST 2015
I'm in the process of trying to understand the LPC15xx CAN rom api so that I can implement it. I don't understand how the SDO processing occurs.  I would think that a message needs to be registered to receive SDO messages, but the documentation says that all message numbers are available for the user for receives or transmits. How are SDO receives handled in the api?

Can anyone help clear this up?

Regards,
Labels (1)
0 Kudos
8 Replies

838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gwlindberg on Wed Sep 30 17:49:28 MST 2015
OK, I guess that that is the clue bat that I needed.  It's just that the documentation doesn't specify what those messages are going to be used for.  And then the sample code reuses message 1 for the PDO messages.

Thanks for the help.
0 Kudos

838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Sep 30 17:24:44 MST 2015

Quote: gwlindberg
In the example code a receive message is set up to receive messages with a COB-ID of 0x400 to 0x4ff.



That's no SDO, that's PDO...


Quote: gwlindberg

If the ROM CAN code is handling SDO messages by itself, then I would expect that it needs to set up a receive message and that that would take up one message slot in the CAN hardware. But the documentation says that the user can use all 32 messages for there own use, so that generates my question, how are the SDO messages received if nothing is set up to receive them?



Of course you have to setup 2 message objects for CANOpen 

You'll find them in canopen_driver.c:

/* CANopen configuration structure */
CAN_CANOPENCFG myCANopen =
{
CAN_NODE_ID,/* node_id */
[color=#f00]1,/* msgobj_rx */
2,/* msgobj_tx */
[/color]1,/* isr_handled */
(uint32_t)NULL,/* od_const_num, set to right value in CANopen initialization */
(CAN_ODCONSTENTRY *)myConstOD,/* od_const_table */
(uint32_t)NULL,/* od_num, set to right value in CANopen initialization */
(CAN_ODENTRY *)myOD,/* od_table */
};
0 Kudos

838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gwlindberg on Wed Sep 30 17:11:20 MST 2015
Yes, I've got that.  What I want to know is how does the CAN interface receive the SDO messages if not receive message has been set up for them.

In the example code a receive message is set up to receive messages with a COB-ID of 0x400 to 0x4ff. But there is no receive message set up to receive SDO messages.  If the ROM CAN code is handling SDO messages by itself, then I would expect that it needs to set up a receive message and that that would take up one message slot in the CAN hardware. But the documentation says that the user can use all 32 messages for there own use, so that generates my question, how are the SDO messages received if nothing is set up to receive them?
0 Kudos

838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Sep 30 17:01:40 MST 2015
In AN11238 you'll find SDO settings in CAN_Node_Def.c:



/*CANopen read-only (constant) Object Dictionary (OD) entries
Used with Expedited SDO only. Lengths = 1/2/4 bytes */
CAN_ODCONSTENTRY myConstOD [] =
{
/* index, subindex,length,value */
{ 0x1000, 0x00, 4, 0x00000000UL },
{ 0x1018, 0x00, 1, 0x00000001UL },/* only vendor ID is specified */
{ 0x1018, 0x01, 4, 0x000002DCUL },/* NXP vendor ID for CANopen */
};
uint32_t NumberOfmyConstODEntries = sizeof(myConstOD)/sizeof(myConstOD[0]);

/*CANopen list of variable Object Dictionary (OD) entries
Expedited SDO with length=1/2/4 bytes and segmented SDO */
CAN_ODENTRY myOD [] =
{
/* index, subindex,access_type | length,value_pointer */
{ 0x1001, 0x00, OD_EXP_RO | 1,(uint8_t *)&Error_Register },
{ 0x1016, 0x00,     OD_EXP_RO | 1,          (uint8_t *)&WatchListLength},
{ 0x1016, 0x01,     OD_EXP_RW | 4,          (uint8_t *)&WatchList[0].value},
{ 0x1016, 0x02,     OD_EXP_RW | 4,          (uint8_t *)&WatchList[1].value},
{ 0x1017, 0x00,     OD_EXP_RW | 2,          (uint8_t *)&CANopen_Heartbeat_Producer_Value},
};
0 Kudos

838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gwlindberg on Wed Sep 30 16:56:06 MST 2015
Yes
0 Kudos

838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Sep 30 16:47:01 MST 2015

Quote: gwlindberg
While the documentation talks about SDO messages, the examples don't set anything up for them...



We are talking about Expedited SDO, aren't we  :quest:
0 Kudos

838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gwlindberg on Wed Sep 30 16:42:04 MST 2015
Hi R2D2,
I've got the example code.  While the documentation talks about SDO messages, the examples don't set anything up for them and that's what got me wondering how SDO receives are handled.

Regards,
0 Kudos

838 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed Sep 30 16:24:14 MST 2015

Quote: gwlindberg
I would think that a message needs to be registered to receive SDO messages, but the documentation says that all message numbers are available for the user for receives or transmits. How are SDO receives handled in the api?



Since there are no CANOpen examples for LPC15xx a good starting point is to use LPC11Cxx samples...

Something like:

https://www.lpcware.com/content/nxpfile/an11238-lpc11cxx-canopen-network-demo-0
0 Kudos