LPC11C14 CAN on-chip, need some help

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

LPC11C14 CAN on-chip, need some help

1,465 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marucmp on Sun Sep 09 23:37:26 MST 2012
This is few fragments of my source code:

void [COLOR=Blue]Config_incoming_message_objects[/COLOR](void){

msg_obj.msgobj = 3;
msg_obj.mode_id = SYNC_ID;
msg_obj.mask    = ~SYNC_ID;

(*rom)->pCAND->config_rxmsgobj(&msg_obj);

msg_obj.msgobj = 4;
msg_obj.mode_id = RxIDnew;
msg_obj.mask = ~RxIDnew;
msg_obj.dlc = 6;

(*rom)->pCAND->config_rxmsgobj(&msg_obj);
}
...

void [COLOR=Green]Transfer_message[/COLOR](void){

msg_obj.msgobj  = 0;
msg_obj.mode_id = TxID;
msg_obj.mask    = 0x0;
msg_obj.dlc     = 8;
msg_obj.data[0] = 0x10 | (LC++ & 0x0F);
msg_obj.data[1] = Inputs & (~freq_mask);
msg_obj.data[2] = Delayed_inputs;
msg_obj.data[3] = RxPDO[0];
msg_obj.data[4] = RxPDO[1];
msg_obj.data[5] = RxPDO[2];
msg_obj.data[6] = RxPDO[3];
msg_obj.data[7] = RxPDO[4];
(*rom)->pCAND->can_transmit(&msg_obj);
}

...

void [COLOR=red]Decode_RxPDO[/COLOR](void){
uint8_t i;
uint8_t mode_mask [4]= {0x03, 0x0C, 0x30, 0xC0};

freq_mask = RxPDO[0];
reading_period = RxPDO[1] * 10;
debounce_time = RxPDO[2] * 10;
for(i=0; i<4; i++)
{
transfer_mode = RxPDO[3] & mode_mask;
}
for(i=4; i<8; i++)
{
transfer_mode = RxPDO[4] & mode_mask;
}
if (RxPDO[5] == SYNC_ID) return;

SYNC_ID = RxPDO[5];

[COLOR=blue]Config_incoming_message_objects[/COLOR]();
}
...

/*CAN receive call back */
/*Function is executed by the Call back handler after
a CAN message has been received */
void CAN_rx(uint8_t msg_obj_num){

uint8_t i;

/* Determine which CAN message has been received */
msg_obj.msgobj = msg_obj_num;
/* Now load up the msg_obj structure with the CAN message */
(*rom)->pCAND->can_receive(&msg_obj);

if (msg_obj.msgobj = 3)
{
[COLOR=Green]Transfer_message[/COLOR]();
}
if (msg_obj.msgobj = 4)
{
for (i=0; i<8; i++)
{
RxPDO = msg_obj.data;
}
[COLOR=Red]Decode_RxPDO[/COLOR]();
}
}

...

int main (void) {
Init_CAN();
[COLOR=Blue]Config_incoming_message_objects[/COLOR]();

while (1);
}


    1.Remote unit is sending periodically empty messages with SYNC-ID (requests). And LPC11C14 receive request (message object 3), and send back answer (message object 0). This stage is working properly.
    2.Sometimes remote unit send message containing some data (may be new SYNC-ID) with RxIDnew. And LPC11C14 receive this message (message odject 4).
Now the problem:
After receiving of message object 4 LPC11C14 stops receiving any message. I can't find out why this happens.:confused: Can anybody help?
0 Kudos
Reply
7 Replies

1,409 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marucmp on Mon Sep 10 02:40:11 MST 2012
Thank you, now working good!
0 Kudos
Reply

1,409 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Sep 10 01:54:21 MST 2012
Use the modern version and read: #5 of http://knowledgebase.nxp.com/showthread.php?t=3138
0 Kudos
Reply

1,409 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marucmp on Mon Sep 10 01:43:53 MST 2012

Quote: Zero
Forgotten to reserve ROM-RAM?



likely...
Already read thishttp://support.code-red-tech.com/CodeRedWiki/EnhancedManagedLinkScripts
Trying to understand
0 Kudos
Reply

1,409 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marucmp on Mon Sep 10 01:42:51 MST 2012
Attached project
0 Kudos
Reply

1,409 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Sep 10 01:37:50 MST 2012
Forgotten to reserve ROM-RAM?
0 Kudos
Reply

1,409 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Marucmp on Mon Sep 10 01:31:00 MST 2012

Quote: Zero
And is doing what?



What did you try already?



You don't show much of your project, so the answer is no :(



Just find out: if received RxPDO[0] = 0 then all working properly! :eek:

And if RxPDO[0] > 0 then CAN_IRQHandler {(*rom)->pCAND->isr();} don't causes procedure CAN_rx... :confused:
0 Kudos
Reply

1,409 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Sep 10 01:06:19 MST 2012

Quote: Aleksandr
After receiving of message object 4 LPC11C14 stops receiving any message.



And is doing what?


Quote: Aleksandr
I can't find out why this happens.:confused:



What did you try already?


Quote: Aleksandr
Can anybody help?



You don't show much of your project, so the answer is no :(
0 Kudos
Reply