Problems with On-Chip CAN-Driver

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

Problems with On-Chip CAN-Driver

1,436 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by luky on Tue Sep 20 07:44:11 MST 2011
I try to use the LPC11C24 with the On-board CAN-Driver.
The Bus is running with 125kbps (<10 Messages per sec.) and another LPc is sending testmessages with the ID 100.
The applications is working fine - except that the Interrupt seems to be aktive the whole time and I can't do anything else with the chip.


My code:

(*rom)->pCAND->init_can(&ClkInitTable[0], 1);    //Initialize the CAN controller
(*rom)->pCAND->config_calb(&callbacks); //Configure the CAN callback functions
NVIC_EnableIRQ(CAN_IRQn);    //Enable the CAN Interrupt
msg_obj.msgobj = 1;
msg_obj.mode_id = 100;
msg_obj.mask = 0x7FF;//100;//; //1= Bit wird verwendet
(*rom)->pCAND->config_rxmsgobj(&msg_obj);

...



void CAN_tx(uint8_t msg_obj_num){
  return;
}

void CAN_rx(uint8_t msg_obj_num){
  
  /* 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);

  printf("REC: Nr.%u: %s", msg_obj_num, msg_obj.data); //Date OK!
 
  if (msg_obj_num == 1)
  {
    //Simply transmit CAN frame (echo) with ID via buffer 2
    msg_obj.msgobj = 2;
    msg_obj.mode_id = 100;
    (*rom)->pCAND->can_transmit(&msg_obj);
  }
}

void CAN_IRQHandler(void)
{
LEDON();

   (*rom)->pCAND->isr(); //call the isr() API located in the ROM

LEDOF();
}
The LED stays on the whole time and the other code isn't executing (I checked with a Scope)

What ist wrong with my Code?
0 Kudos
Reply
6 Replies

1,313 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by yanvasilij on Tue Feb 28 03:11:37 MST 2012

Quote: Zero
No, normal is still RAM area mentioned in user manual:



But It doesn't work without it
0 Kudos
Reply

1,313 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Feb 28 03:05:44 MST 2012

Quote: yanvasilij
Also I increased protected RAM area to 0x10000000-0x10000250. Does it normal?



No, normal is still RAM area mentioned in user manual:

Quote:

On-chip RAM from address [COLOR=Red]0x1000 0050 to 0x1000 00B8[/COLOR] is used by the CAN API. This address range should not be used by the application.

0 Kudos
Reply

1,313 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by yanvasilij on Tue Feb 28 02:24:02 MST 2012
Problem solved! I declared array uint8_t id_table[255]. When I exchaged it to id_table[50] it had started working. Also I increased protected RAM area to 0x10000000-0x10000250. Does it normal?

Another one question: My CANopen master gets messagse from many nodes. That why I have to use several message objects for reciving. When CANrx interrupt occurs I use the following rotine:
os_evt_wait_or (EVT_CAN_int, 0xFFFF);//It is RTX rotine. It wait until CANrx interrupt is not happen
mob_amount = msg_obj.msgobj;
for(mob_num = 0; mob_num <= mob_amount; mob_num++)//read and process all used messages objects 
{
NVIC_DisableIRQ(CAN_IRQn);
msg_obj.msgobj = mob_num;
(*rom)->pCAND->can_receive(&msg_obj);//read mob_num message object
id = msg_obj.mode_id;
len = msg_obj.dlc;
for(i = 0; i<8; i++) data = msg_obj.data;
NVIC_EnableIRQ(CAN_IRQn);

//process data from this message object
...
...
//------------------------------------

}

But not all messages processed. What is wrong?
0 Kudos
Reply

1,313 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by yanvasilij on Tue Feb 21 22:44:10 MST 2012
Hello! I built a project in keil for lpc11c24. Source code is bellow. Program always stop on (*rom)->pCAND->init_can(&ClkInitTable[0], 1). I completely don't know what's wrong:mad:: I protected memory for ROM api functions (lived ample reserv: 0x10000000-0x10000180), checked CAN_on-chip initialization (it works with another program), checked clock initialization (CPU freq = 48 MHz, scoped on PIO0_1 - 4,8 MHz). Could somebody advise to me something?
0 Kudos
Reply

1,313 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by luky on Tue Sep 20 09:28:26 MST 2011
The Code is from the can_onchip sample, I don't use Canopen.
printf is retargeted to the USART (for debugging purposes)
The Application works fine until I initialize the CAN-Driver.
0 Kudos
Reply

1,313 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Sep 20 08:13:19 MST 2011
#1 Is this a 100% copy of canopen sample? If not, what did you do to reserve CAN RAM :confused:

#2 What's this printf doing there? Is this a semihosting project :eek:

#3 Please post complete files and projects :)
0 Kudos
Reply