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?