Ignored CAN messages

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

Ignored CAN messages

503 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Harrie on Tue Dec 08 09:05:54 MST 2015

For a project we initialize multiple message objects, each object is set to only receive messages from one particular id.

The problem we are facing is that after a certain period those messages are ignored.
This problem only seems to occur when we periodically transmit CAN-messages from the LPC11CXX.

Is there a solution to fix this problem?

Kind regards,
Harrie
Labels (1)
0 Kudos
6 Replies

428 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Harrie on Wed Dec 30 09:16:23 MST 2015
Here is yet another workaround which seems to work.

This has been achieved by defining two separate CCAN_MSG_OBJ structures for receive and transmit (see below).
Here the msg_obj_rx is used in the CAN_rx() function and in the CAN_Init() function.
Whereas the msg_obj_tx is used in the main() function to transmit CAN messages.

I would please like to hear if this is a correct solution, or if there are also other ways to solve this issue.


can.c

#include "lpc_types.h"
#include "can.h"

CCAN_MSG_OBJ_T msg_obj_rx;
CCAN_MSG_OBJ_T msg_obj_tx;
uint8_t data_0;
uint8_t data_1;

/*CAN receive callback */
/*Function is executed by the Callback handler after a CAN message has been received */
void CAN_rx(uint8_t msg_obj_num) {
msg_obj_rx.msgobj = msg_obj_num;// Determine which CAN message has been received
LPC_CCAN_API->can_receive(&msg_obj_rx);// Now load up the msg_obj structure with the CAN message

data_0 = msg_obj_rx.data[0];
data_1 = msg_obj_rx.data[1];
LPC_GPIO3->DATA ^= (1 << 0);// Switch LED
}

/*****************************************************************************
 ** Function name:CAN_Init for initializing the CANbus
 *****************************************************************************/
void CAN_Init(uint32_t CAN_baudrate) {

uint32_t initTable[2];
initTable[0] = 0x05; // 48 Mhz/(5+1) -> 8 MHz
initTable[1] = CAN_baudrate; // configure bit rate to 250k

LPC_CCAN_API->init_can(&initTable[0], 1); // Initialize the CAN controller

/* Publish CAN Callback Functions */
CCAN_CALLBACKS_T callbacks = { CAN_rx,CAN_tx, CAN_error, NULL, NULL, NULL, NULL, NULL };

LPC_CCAN_API->config_calb(&callbacks);// Configure the CAN callback functions

/* Enable the CAN Interrupt */
NVIC_EnableIRQ(CAN_IRQn);

/*  Configure message object 1 to receive only common messages from 0x0FA‬ */
msg_obj_rx.msgobj =0x01;
msg_obj_rx.id =0xFA;
msg_obj_rx.mask =0x1FFFFFFF;
LPC_CCAN_API->config_rxmsgobj(&msg_obj_rx);
}


int main(void) {

...
while (1) {

if (LPC_TMR32B0->IR & (1 << 0)) {// check interrupt 0

msg_obj_tx.msgobj= 28;
msg_obj_tx.id= 0x7CC;
msg_obj_tx.dlc= 2;
msg_obj_tx.data[0]= data_0;
msg_obj_tx.data[1]= data_1;
LPC_CCAN_API->can_transmit(&msg_obj_tx);

LPC_TMR32B0->IR |= (1 << 0);// clear interrupt 0
}
...


0 Kudos

428 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Harrie on Tue Dec 15 09:47:37 MST 2015
Hey, thank you for your input.

I found a temporary workaround by adding the command __WFI(); to the while in the main function.
However the __WFI(); command is causing a sleep mode if there is no CAN RX message.
Therefore this solution is not favorable.

Does anyone have a clue why this helps?



0 Kudos

428 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 3CPO on Tue Dec 15 02:43:22 MST 2015
Hi Harrie,

I checked your code and I sow that you use the CMSIS library (version 2p00).

Could that be the issue? May be there is a bug in 2p00 version of the CMSIS  LIB with related with CAN?

Does anybody know if the latest CMSIS LIB version is 2p00?
0 Kudos

428 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Harrie on Mon Dec 14 07:49:34 MST 2015
Thank you for your input.
I managed to strip down the code, I hope this makes locating the problem easier.

The error occurs after approximately 15 to 20 minutes. (i.e. the content of data_0 and data_1 isn't updated)

Below are the project properties, to reserve RAM for the can message buffer and can API.

C/C++ Build > MCU settings
Memory details (LPC11C22/301)*

TypeNameAliasLocationSize
FlashMFlash16Flash0x00x4000
RAMRamLoc8RAM0x100000c00x1f20

C/C++ Build > Settings
MCU Linker > Managed Linker Script
Manage linker scriptEnabled
Enable Code Read ProtectDisabled
Link application to RAMDisabled
Stack offset32
LibraryRedlib (none)

Looking forwards to the solution.

Kind regards,
Harrie
0 Kudos

428 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Sat Dec 12 02:38:32 MST 2015

Quote: 3CPO
CAN somebody help us?



Obviously not  :((

Without code (=project) and detailed description (hardware) chances are low...
0 Kudos

428 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by 3CPO on Fri Dec 11 10:14:02 MST 2015
hi,

I have same issue. There is a post at https://www.lpcware.com/content/forum/on-chip-can-tranceiver

CAN somebody help us?
0 Kudos