Forums

problem in using timer interrupt at TSK

Started by ahmadagha23 December 26, 2005
hi;
I want to toggle LED_2 on DSK6711 every 0.4 second in the following
manner: I use a task in which initializing timer1 as
the interrupt source (int15 in DSP/BIOS) to doing the "timer1int()"
for toggeling LED_2. But when I run my program it sends
a reset emulator message, or some times, it is running whitout
toggling the LED_2. Do you know why? and do you have any idea about
sampling an input signal in 2.5 sample per second?
thanks it is my program:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <std.h>
#include <log.h>
#include <swi.h>
#include <sem.h>
#include <clk.h>

#include <csl.h>
#include <bsl.h>
#include <csl_irq.h>
#include <csl_dat.h>
#include <csl_cache.h>
#include <csl_mcbsp.h>
#include <csl_timer.h>

void main()
{

CACHE_flush(CACHE_L2ALL,0,0);

}

/********************************************************************
**********\
* End of main.c
\********************************************************************
**********/

void tskMainFunc()
{ TIMER_Handle hTimer;
volatile Uint32 x,y;

CSL_init();
BSL_init();
hTimer=TIMER_open(TIMER_DEV1,0);
TIMER_configArgs(hTimer,0x381,0x7270e0,0);
TIMER_start(hTimer); ICR=0x8000;
IER= IER | 0x8003;
CSR= CSR | 1;

while (1){
LED_toggle(LED_1);
}
} interrupt void timer1int()
{
LED_toggle(LED_2);
return;
}


Ahmad-

> I want to toggle LED_2 on DSK6711 every 0.4 second in the following
> manner: I use a task in which initializing timer1 as
> the interrupt source (int15 in DSP/BIOS) to doing the "timer1int()"
> for toggeling LED_2. But when I run my program it sends
> a reset emulator message, or some times, it is running whitout
> toggling the LED_2. Do you know why? and do you have any idea about
> sampling an input signal in 2.5 sample per second?

I see a "while (1)" in your code for tskMainFunc() below. How will you
return control to the OS? It doesn't look to me like any task can run
once tskMainFunc() gets a grip.

Other suggestions:

1) Move CSL_init() and BSL_init() to main().

2) Create a PRD (periodic) task to toggle LED_2.

3) TIMER1 initialization in tskMainFunc() is Ok as long as it runs only once.

-Jeff

> it is my program: >
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
>
> #include <std.h>
> #include <log.h>
> #include <swi.h>
> #include <sem.h>
> #include <clk.h>
>
> #include <csl.h>
> #include <bsl.h>
> #include <csl_irq.h>
> #include <csl_dat.h>
> #include <csl_cache.h>
> #include <csl_mcbsp.h>
> #include <csl_timer.h>
>
> void main()
> {
>
> CACHE_flush(CACHE_L2ALL,0,0);
>
> }
>
> /********************************************************************
> **********\
> * End of main.c
> \********************************************************************
> **********/
>
> void tskMainFunc()
> { > TIMER_Handle hTimer;
> volatile Uint32 x,y;
>
> CSL_init();
> BSL_init(); >
> hTimer=TIMER_open(TIMER_DEV1,0);
> TIMER_configArgs(hTimer,0x381,0x7270e0,0);
> TIMER_start(hTimer); > ICR=0x8000;
> IER= IER | 0x8003;
> CSR= CSR | 1;
>
> while (1){
> LED_toggle(LED_1);
> }
> } > interrupt void timer1int()
> {
> LED_toggle(LED_2);
> return;
> }