The LPC1114 demo from ChibiOS works. So does the CAN bus slave example for LPC11C24 from NPX in the LPCxpresso IDE environment.
My next thought was to try and get the code from App Note AN11238 to work under ChibiOS. Integration so far was fairly straightforward - copying a few source files into the LPC1114 demo and adding them to the compile/link steps in the Makefile. Here's is the main code I'm trying out:
Code: Select all
int main(void) {
halInit();
chSysInit();
CANopenInit();
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
...
The CANopenInit() call is standard boilerplate, which I think ties into the ROM code. A quick browse indicates that it sets up the CAN device interrupt.
(I'm not using the ChibiOS CAN driver, because there is none for LPC a.t.m.)
Stepping through the first few lines, I can see that chThdCreateStatic() gets called but it never returns. The non-RTOS App Note code is as follows:
Code: Select all
int main(void)
{
SystemInit();
CANopenInit();
/* Timer16B0 */
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7); /* Enable clock for 16-bit counter/timer 0 */
LPC_TMR16B0->MCR = 3; /* Interrupt and Reset on MR0 */
LPC_TMR16B0->MR0 = SystemCoreClock/1000; /* Interrupt and Reset on MR0 */
NVIC_EnableIRQ(TIMER_16_0_IRQn); /* Enable the Timer0 Interrupt */
LPC_TMR16B0->TCR = 1; /* Enable Timer0 */
/*LEDArray */
LPC_GPIO2->DIR |= 0x000000FF; /* LEDs as output */
LEDArray = 0x00;
while(1)
{
__WFI(); /* Go to Sleep */
}
return 0 ;
}
SystemInit() seems to be standard LPC-speak for setting up the clocks. Then the same CANopenInit() call, then a timer which gets called to keep the CAN protocol / state machine going, and that's it.
One detail which might be messing things up is RAM memory use - from UM10398, p.313:
On-chip RAM from address 0x1000 0050 to 0x1000 00B8 is used by the CAN API. This address range should not be used by the application. For applications using the on-chip CAN API, the linker control file should be modified appropriately to prevent usage of this area for application’s variable storage.
I don't know whether this is relevant, and haven't yet figured out where to make such a change in the ChibiOS source tree...
Any suggestions as what could be going on, or how to narrow this down?
-jcw
UPDATE: moving the RAM usage up in LPC1114.ld (ram : org = 0x10000400, len = 7k) doesn't seem to make a difference, although the map indicates the RAM mappings have indeed shifted up.