LPC11Cxx CCAN and freertos problems.

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

LPC11Cxx CCAN and freertos problems.

1,261 Views
dimanechaev
Contributor II

Hello. 

I've downloaded examples for LPC11Cxx. Here i've found examples for freertos(nxp_lpcxpresso_11c24_freertos_blinky) and  CAN(nxp_lpcxpresso_11c24_periph_ccan_rom). Everything works. But when i try to use CAN in FreeRTOS examples - it doesnot work correctly. I always get vApplicationStackOverflowHook for task there i try to init CAN. Overflow happens every time i try to use CAN ROM function. For example that one LPC_CCAN_API-> init_can ( &CanApiClkInitTable[0], TRUE); 
It does not matter how big is stack for task where i call this function. Does anybody knows how to handle this? 

Labels (1)
6 Replies

1,023 Views
ekki
Contributor III

Hello Dima,

did you consider the RAM-section, that the C_CAN API uses? See User Manual UM10398  chapter 17.4.1 saying that it uses RAM location 0x1000 0050 to 0x1000 00B8.

Because of that I have set in the MCU settings the RAM start that usually is 0x1000 0000  to 0x1000 00C0. 

Does anybody know a smarter  solution for that problem? 

1,023 Views
ekki
Contributor III

I just found a smarter solution. Watch here: ..../CodeRedWiki/EnhancedManagedLinkScripts

1,023 Views
dimanechaev
Contributor II

I also changed memory regions in MCU settings. I did one region before 0x10000050 and one after 0x100000B8. I did not use manual linker files in LPCXpresso.

0 Kudos
Reply

1,023 Views
dimanechaev
Contributor II

Hello Ekkehard.

I didnot consider that. Thank you very much.

0 Kudos
Reply

1,023 Views
FreeRTOS_org
Contributor IV

I assume when you say it doesn't matter how big the stack is you are increasing the stack size using the usStackDepth parameter in the call to xTaskCreate() or xTaskCreateStatic()?  If so, and the stack size is really not the issue, could it be something else is simply writing over the memory used by the stack?  Writing over the memory would corrupt the pattern that marks the end of the stack, which would then be detected as an overflow.

Are you using any stack heavy/hungry functions like printf() or sprintf()?  If so, try taking those out.

0 Kudos
Reply

1,023 Views
dimanechaev
Contributor II

Hello Richard. Thank you for your answer. I realy tried to increase usStackDepth. It didnot help. I didnot use stack heavy/hungry functions like printf() or sprintf().  Here is an example of my problem:

void main()

{

...

xTaskCreate(vTask0, (signed char *) "vTask0", configMINIMAL_STACK_SIZE*5, NULL, (tskIDLE_PRIORITY + 1UL),(xTaskHandle *) NULL);

...

}

static void vTask0(void *pvParameters) {

   uint32_t CanApiClkInitTable[2];
   /* Publish CAN Callback Functions */
   CCAN_CALLBACKS_T callbacks = {
      CAN_rx,
      CAN_tx,
      CAN_error,
      NULL,
      NULL,
      NULL,
      NULL,
      NULL,
   };
   baudrateCalculate(TEST_CCAN_BAUD_RATE, CanApiClkInitTable);

   LPC_CCAN_API->init_can(&CanApiClkInitTable[0], TRUE);

/// here comes task stack overflow!!!


   /* Configure the CAN callback functions */
   LPC_CCAN_API->config_calb(&callbacks);
   /* Enable the CAN Interrupt */
   // NVIC_EnableIRQ(CAN_IRQn);

   /* Send a simple one time CAN message */
   msg_obj.msgobj = 0;
   msg_obj.mode_id = 0x123;
   msg_obj.mask = 0x0;
   msg_obj.dlc = 4;
   msg_obj.data[0] = 'T'; // 0x54
   msg_obj.data[1] = 'E'; // 0x45
   msg_obj.data[2] = 'S'; // 0x53
   msg_obj.data[3] = 'T'; // 0x54
   LPC_CCAN_API->can_transmit(&msg_obj);

   /* Configure message object 1 to receive all 11-bit messages 0x400-0x4FF */
   msg_obj.msgobj = 1;
   msg_obj.mode_id = 0x100;//0x400;
   msg_obj.mask = 0x700;
   LPC_CCAN_API->config_rxmsgobj(&msg_obj);

}

0 Kudos
Reply