cancel
Showing results for 
Search instead for 
Did you mean: 

can't make timer A int work

adi2
Associate II
Posted on November 13, 2003 at 03:52

can't make timer A int work

6 REPLIES 6
adi2
Associate II
Posted on November 12, 2003 at 08:15

hi !!

i need your help make timer A (and any type of INT )Work.

i use the st72264 ,the indart-stx and the metrowerks compiler.

i worte a small application that changes the state of RB port every time Timer A overflow.

i encounter 2 issues :

1. the INT does not work

2. when i write TACR1 = TOIE ;

asm RIM;

i can not communicate with the Micro controller i get an error

''communication error between the indart and the target device''

what can be the reason for that ?

i add the small application please advise:

unsigned char i=1;

unsigned char temp=0;

unsigned char Data=0b10101010;

void main(void)

{

PBDDR = 0xFF;

PBOR = 0XFF;

/* 16 bit timer */

TACR1 = TOIE ;

TACR2 = Fcpu8;

asm RIM;

while(1) {

}

}

interrupt 4 void TIMER_A_INT (void)

{

if (TASR & TOF)) /* the TOF flag is on */

{

temp=TASR; /* for reading the TASR */

TACLR=0; /* clearing the TOF flag */

if (ValBit(Data,i))

PBDR=0xFF;

else

PBDR=0;

i++;

if (i==9)

i=1;

}

}

Adi.

seeguard
Associate II
Posted on November 12, 2003 at 09:50

I can tell you how it works on ST72F521

1. take a look of the attached file ( vector addres define in *.prm)

(your syntax I think it's good for a cosmic compiler.)

2. initialization of registers:

void TimerA_init_F(void)

{

asm(''sim''); // Disable all interrupts.

TACR1=0b00000000;

TACR2=0b00000000;

TOIE=1; // enable interrupt for timer A

TACHR = TICK_COUNTER_HIGH; // measurment xx msec value

TACLR = TICK_COUNTER_LOW;

freeTimerA = TACR;

ISPR2 = 0b11111100; // interrupt no.8 bit0&1 priority level 2. if the are 11 the timer A interrupt is disable.

asm(''rim''); // Enable interrupts.

}

3. interrupt syntax (metrowerks) timer A example

#pragma TRAP_PROC SAVE_REGS

/*-----------------------------------------------------------------------------

ROUTINE NAME : tima_rt

INPUT/OUTPUT : None

DESCRIPTION : timer Interrupt Service Routine

COMMENTS :

-----------------------------------------------------------------------------*/

void tima_rt(void)

{

UINT8 r_status;

r_status = TASR; // 1 must be read

SET_STATUS(TASK_1MS);

TACHR = TICK_COUNTER_HIGH;

TACLR = TICK_COUNTER_LOW; // 2must read/write ( 1 & 2 clear the TOF

TickCount++;

if ( TickCount > TICKS_PER_SECONDS )

{

if(!toggle)

RD0=1;

else

RD0=0;

toggle =~toggle;

SET_STATUS(TASK_1SEC);

TickCount = 0;

}

}

4. good luck !

atz

________________

Attachments :

This_is_a_generic_Prm_File.doc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0H4&d=%2Fa%2F0X0000000bWU%2FZAmuCpSyf8LOpDoOuYJRzpxOJgdF28eTuXjW8srXDbQ&asPdf=false
sjo
Associate II
Posted on November 12, 2003 at 13:09

There are two ways of declaring an interrupt function in metrowerks.

1. Using the #pragma TRAP_PROC, with this you have to declare hte INTERRUPT addresses in the prm file.

2. use interrupt 1 void trap() - this is set for the trap function. The advantage of this is no mods to the prm file have to be done.

PS.

it should be configured: interrupt 6 void TIMER_A_INT() for timer a interrupt.

Regards

sjo
adi2
Associate II
Posted on November 12, 2003 at 13:29

thanks datzmon

and sjo

your last line ''it should be configured: interrupt 6 void TIMER_A_INT() for timer a interrupt''

fix every thing to me cause in the datasheet i'm holding it is written that for timer A int the number is 4 !!.

i have the august 2003 rev 1.7 .

is it the last version ?

am i right ?

adi.

sjo
Associate II
Posted on November 12, 2003 at 14:13

you have the latest datasheet, however metrowerks use interrupt 0 as reset, 1 as trap etc. this would make timer a interrupt 6. Its just that st don't count reset and trap.

Regards

sjo
adi2
Associate II
Posted on November 13, 2003 at 03:52

thanks alot.

adi.