In a task I call Task_sleep(1). It never returns to my code. I even modified the code to eliminate all interrupts. The only thing running is this task.
Any idea why Task_sleep will not return?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
In a task I call Task_sleep(1). It never returns to my code. I even modified the code to eliminate all interrupts. The only thing running is this task.
Any idea why Task_sleep will not return?
This problem has occurred a lot.
Check out these forum posts to see if your scenario has already been addressed:
http://e2e.ti.com/search/default.aspx#q=Task_sleep&g=231&sc=forum
Alan
None of those posts worked for my problem.
according to the ROV:
- a timer is setup for timer 0.
- Clock ticks is always 0
- I set a breakpoin on the timer HWI but it is never called. IE14 is enabled
in addition:
- disabled all HWI in my code. nothing is running except my task and the system idle task
- timers are always enabled on the c6748
- timer0 seems to be setup correctly in the hardware
--- TCR.ENAMODE12=EN_CONT, PRD12=0x00249f00, INTCTLSTAT.PRDINTEN12=ENABLE, INTCTLSTAT.PRDINTSTAT12=PEND
--- if I disable PRDINTEN12, run, enable PRDINTEN12, run, then I get an HWI and a return from Task_sleep (but only one...)
another part of the code and it works fine
If the program truly NEVER comes back from Task_sleep(), it sometimes means that BIOS thinks the timer it uses for its Clock tick interrupt is being clocked at 32KHz when in fact its being clocked at 20Mhz (for instance). BIOS would then configure the timer period to a VERY small number (ie 32) when it should be setting it to 20,000. This results in the application being completely overrun with interrupts and never getting to the job of servicing the Task_sleep() timer.
Can you confirm what frequency your GEL file is configuring the timers to run?
Using the Timer ROV view, you can see what the timer period is set to.
What board and CPU are you using? Also, which version of SYS/BIOS?
Alan
Hmm. I see now that the period register is set to 2,400,000. At 24MHz, that would yield a period of 100ms. Have you set the Clock.tickPeriod to 100,000?
If the program ultimately does return from Task_sleep() but after taking way too much time, its probably due to the opposite mismatch. BIOS thinks the timer is being clocked at 24Mhz when in fact it is being clocked at 32KHz. This results in the timer period being set WAY too high. What should have been a 1ms interrupt period turns into a 750 x 100ms period (ie 75 seconds per tick).
Alan
clock source is INTERNAL which is 24Mhz. I have not set the Clock.tickPeriod to anything. I have stopped the debugger at various points. TIM12 is variously higher and lower meaning that it is obviously timing out and recycling.
the program does not ever return from Task_sleep()
from my DISABLE/ENABLE test it appears something is wrong with the timer interrupt.
Hmmm.
Can you try configuring the Clock module to use a different timer?
Clock.timerId = 1; /* or 2 or 3 */
Alan
Timer 1 & 2 are used in my hardware. and...setting the clock to use timer 3 works!
that begs the question...what could I be doing to mess up using timer 0?
on the other hand...I made a copy of the timer registers when using timer 0 and timer 3. the file is attached. significant differences are in the table below
0 3
PRD12 0x00249F00 0x000249F0
TGCR 0x00000017 0x0000000F
INTCTLSTAT 0x00000003 0x00000000
Kurt,
Somehow, the BW bit (bit 4) is set in the TGCR for timer 0.
I think this may be enabling some kind of input capture feature which may be interfering with the normal operation of the Timer.
Are you setting this bit?
Alan
I looked at my code and confirmed that it was not using timer 0.
but...we are using the usblib from the c6748 StarterWare and it uses timer 0 to count delays. my bad!
Aha!
Great work!
Now we have another reason for Task_sleep() not returning.
Alan