Content originally posted in LPCWare by rody on Fri Sep 11 00:21:11 MST 2015
I changed the code:
There is one task what inits the ADC/DMA when started and in the while(1) loop every second a '.' is send to the uart (blocking). A '#"is send on the DMA interrupt.
Before init a while(!start) loop is added. The debugger is needed break the loop so the code continues.
- I program the target and run it on the debugger with attach only false -> the runs fine.
- Then a disconnect the debugger en power cycle the target. The code is running until the while(!start) loop.
- Now the debugger is connected, with attach only true.
- When I now pause the debugger, it hangs in the while(!start) loop. With the debugger I set start to 1, breaking the loop and run the code again
- In the msDelay(10000) remove the debugger connector from the target,
So basically only the while(!start) and a part of the msDelay(10000) is executed using the debugger, no real code what maters.
Result: The code is working!
It seems that only attaching and executing some code with the debugger is enough to let it work. What does the debugger do in SWD mode? Is there some kind of init?
And what has Freertos to do with it? I tested before in previous code that I works fine when Freertos is not running (vTaskStartScheduler() not executed).
//--
static xTaskHandle xTestTaskHandle = NULL;/* Holds the handle of the Debug task. */
static void TestTask(void *pvParameters)
{
volatile int start=0;
Chip_UART_SendStringBlocking(LPC_UART0, "\r\nWait... \r\n");
while(!start);
msDelay(10000);
Board_ADC_Init();
Chip_UART_SendStringBlocking(LPC_UART0, " After ");
while (1)
{
Chip_UART_SendStringBlocking(LPC_UART0, ".");
msDelay(1000);
}
}
static void Board_TestStartTask(void)
{
xTaskCreate(TestTask, "TTest ",
configMINIMAL_STACK_SIZE,
NULL,
2,
&xTestTaskHandle);
}
//--
/**
* @briefmain routine
* @returnNothing, function should not exit
*/
int main(void)
{
SystemCoreClockUpdate();
Board_Init();
Board_DebugUart_Init();
Board_TestStartTask();
vTaskStartScheduler();
while(1);
/* Should never arrive here */
return 1;
}
//--