Hello,
I am trying to use the ADC1 on the Tower evaluation board with K60.
For initialisation I use the Processor Expert (see attetchment) and this is the start code:
[code]adc1Data=ADCPoti_Init(NULL);
ADCPoti_SelectSampleGroup(adc1Data, 0);
ADCPoti_StartLoopMeasurement(adc1Data);[/code]
After calling StartLoopMeasurement() the whole system hangs, not even the jtag debugger is able to pause the system. Interesting is, with disabled interrupt for ADC1 everything works fine, exept the interrupt of course.
With interrupt enabled, the interrupt handler it is called once and never again. Is there something I have to do in the interrupt or what is my problem?
Hello,
could you please post here the whole project that leads you to getting the error?
best regards
Vojtech Filip
Processor Expert Support Team
Of course. I atteched the whole Eclipse project.
He should create a sine wave on DAC0_OUT and toggle the Pin PTC1 each time the ADC interrupt handler is called.
The ADC0 runs in free run mode, capturing the state of the poti of the tower board (ADC1_DM1).
The main loop will create the sine wave with a frequency depending on the ADC value.
We have reproduced the same behavior, the project freezes after a while. It seems that the problem is related to usage of floating point math and interrupts. I have reproduced the same behavior with new simple project containing just one timer interrupt and main loop containing floating point expression and assignment.
As a workaround it seems to work to disable interrupts as you did or removing floating point calculation.
I have asked compiler team to check this issue.
best regards
Petr Hradsky
Processor Expert Support Team
Hi
We are seeing a similar thing using floating point trig. The CPU seems to freeze along with the debugger. Has there been any progress in resolving this?
Thanks, Norman
It seems that this is a problem of my main loop:
[code] while(1)
{
//Cpu_DisableInt();
DA1_SetValue(dac1Data, (((uint16_t)((sin(dacX)+1.0)*2047.0))&0x00000fff));
dacX+=((double)adc1_value)/255.0*0.04;
if(dacX>2*3.14159265)
dacX=0.0;
//Cpu_EnableInt();
for(i=0; i<10000; i++)
asm("nop");
//GPIOD_PTOR = (1<<6);
}[/code]
With this code the cpu crashes after a few seconds, uncommenting the Cpu_DisableInt() and Cpu_EnableInt(); functions solves this problem. I tryed to find out which command is responsible for that but it seems like all commands are. Is it a problem with the floating point operations? Maybe they are not interruptable? Any idea?