Hello,
I am doing a project where I have an ADC sampling at 1 MHz, with the samples transferred to memory via uDMA, and then sent to a computer via a TCP connection.
I am using TI-RTOS, where I have one task object initializing the ADC, uDMA, and the timer - which works. I have another task object that is created inside netOpenHook(), which creates the TCP server and handles incoming connections - which works.
My problem is: I can't get both task objects to work at the same time. Specifically, I can see that uDMA is working by checking the memory browser, and seeing that the memory is changing according to the signal that I'm passing into the ADC. But the program seems to halt there, no TCP server is created.
I've narrowed down the problem (to my understanding) to a particular code segment:
Void ADC_init_task(UArg arg0, UArg arg1) {
uint32_t ui32ClockFreq;
// Set clock frequency
ui32ClockFreq = SysCtlClockFreqSet(
SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL
| SYSCTL_CFG_VCO_480, CLK_FREQ);
dma_init();
dma_start(25, CHAN_A);
adc_init();
adc_trigger_timer_init(ui32ClockFreq, 1000000);
System_printf("ADC_init_task: Done\n"); System_flush();
}
In the above code, the line:
System_printf("ADC_init_task: Done\n"); System_flush();
Is never run (or I'm not seeing it in the console).
I have commented out the lines, and deduced that the error should be from:
adc_trigger_timer_init(ui32ClockFreq, 1000000);
Which is:
void adc_trigger_timer_init(uint32_t ui32ClockFreq, uint32_t ui32SampleFreq) {
// Enable timer peripheral clock
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
while (!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER1)) {
}
TimerConfigure(TIMER1_BASE, TIMER_CFG_A_PERIODIC_UP);
TimerLoadSet(TIMER1_BASE, TIMER_A, (ui32ClockFreq / ui32SampleFreq));
TimerControlTrigger(TIMER1_BASE, TIMER_A, true);
TimerADCEventSet(TIMER1_BASE, TIMER_ADC_TIMEOUT_A);
System_printf("Enabling timer\n");
System_flush();
TimerEnable(TIMER1_BASE, TIMER_A);
System_printf("Finished enabling timer\n");
System_flush();
}
In the above code, the line:
TimerEnable(TIMER1_BASE, TIMER_A);
Causes the program to halt there, so "Finished enabling timer\n" is not printed to the console.
I did notice that commenting out the line:
TimerControlTrigger(TIMER1_BASE, TIMER_A, true);
Will make halting go away, and I am able to make TCP connections once again, but then I won't be able to get ADC samples, since the ADC isn't being triggered by the timer.
How do I fix this? Any help would be much appreciated. Thanks
I've attached my project to this post, if that helpsDigiscope.rar