cancel
Showing results for 
Search instead for 
Did you mean: 

sos,why TIMERB_INT cannt exit interrup.sos!!!

hzcoffee
Associate II
Posted on August 11, 2004 at 13:29

sos,why TIMERB_INT cannt exit interrup.sos!!!

7 REPLIES 7
hzcoffee
Associate II
Posted on August 01, 2004 at 14:36

i use timerb_oc1 for 1ms timer, enter oc2 int but ,cannt exit interrup,why?

please tell me exit interrup other condition.thank you.

void INT_Timer2 (void)

{unsigned char temp;

if(TIM2_SR&0x40)

{

temp = M2_SR; /* Clear all flags */

temp = TIM2_OC1L;

TIM2_OC1H= 0x03; /* Load OC1R value */

temp = TIM2_SR; /* Clear all flags */

TIM2_OC1L =0xe8;

TIM2_ACL = TIMER_DEFAULT;

/* Reset counter to 0xFFFC */

}

if(TIM2_SR&0x0

{

temp = TIM2_SR; /* Clear all flags */

temp = TIM2_OC2L;

TIM2_OC2H= 0xFF; /* Load OC1R value */

temp = TIM2_SR; /* Clear all flags */

TIM2_OC2L =0x00;

}}

main(){

TIM2_SR &= 0xFB;

TIM2_CR1 |= 0x40; /* Enable timerA interrupts */

TIM2_OC1H= 0x03; /* Load OC1R value */

TIM2_OC1L =0xe8;

}

juhee
Associate II
Posted on August 02, 2004 at 12:13

IF you are using Hiware or Metrowerks compiler use the Keyword

#pragma TRAP_PROC SAVE_REGS

before the interrupt routine definition

If you are using Cosmic Compiler then use the keywrod

@interrupt

For example

@interrupt void TIMER_INT(){

.............

...............

}

or

#pragma TRAP_PROC SAVE_REGS

void TIMER_INT(){

.............

...............

}

These keywords allows the compiler to treat the Routine as an Interrupt routine. Thus adds the IRET instruction at the end of dissasembly of that Particular routine.

Also dont forget to Place the Interrupt routine correctly in the Interrupt Vector Table for your Project

hzcoffee
Associate II
Posted on August 04, 2004 at 12:20

i have checked my code

pragma TRAP_PROC SAVE_REGS

void INT_Timer2 (void)

VECTOR ADDRESS 0xffe8 INT_Timer2

has been add.

juhee
Associate II
Posted on August 05, 2004 at 10:22

In the Interrupt Routine also check for Overflow flag, if it is set then clear it. Because the interrupt Routine for Overflow and Output Compare is same. So once the Interrupt is generated the control could reenter in to the Routine untill all the Flags are cleared.

hzcoffee
Associate II
Posted on August 05, 2004 at 13:58

i have been found wrong ,in my map file

SEGMENT ''TIMA''

TIM1_SR 31 1 ( 1) TIMA

TIM1_IC1L 32 1 ( 1) TIMA

TIM1_OC1L 33 1 ( 1) TIMA

TIM1_CNTL 34 1 ( 1) TIMA

TIM1_IC2L 35 1 ( 1) TIMA

TIM1_OC2L 36 1 ( 1) TIMA

SEGMENT ''TIMB''

TIM2_CR2 41 1 ( 3) TIMB

TIM2_CR1 42 1 ( 2) TIMB

TIM2_SR 43 1 ( 4) TIMB

TIM2_IC1L 44 1 ( 1) TIMB

TIM2_OC1L 45 1 ( 2) TIMB

TIM2_ACL 46 1 ( 2) TIMB

TIM2_IC2L 47 1 ( 1) TIMB

TIM2_OC2L 48 1 ( 2) TIMB

st72c define

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

ST72321 Timer A Internal Registers

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

#pragma DATA_SEG SHORT TIMA

volatile unsigned char TIM1_CR2; /* control register 2 */

volatile unsigned char TIM1_CR1; /* control register 1 */

volatile unsigned char TIM1_SR; /* status register */

volatile unsigned char TIM1_IC1H; /* input capture 1 high */

volatile unsigned char TIM1_IC1L; /* input capture 1 low */

volatile unsigned char TIM1_OC1H; /* output compare 1 high */

volatile unsigned char TIM1_OC1L; /* output compare 1 low */

volatile unsigned char TIM1_CNT; /* counter high */

volatile unsigned char TIM1_CNTL; /* counter low */

volatile unsigned char TIM1_ACH; /* alternate counter high */

volatile unsigned char TIM1_ACL; /* alternate counter low */

volatile unsigned char TIM1_IC2H; /* input capture 2 high */

volatile unsigned char TIM1_IC2L; /* input capture 2 low */

volatile unsigned char TIM1_OC2H; /* output compare 2 high */

volatile unsigned char TIM1_OC2L; /* output compare 2 low */

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

ST72321 Timer B Internal Registers

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

#pragma DATA_SEG SHORT TIMB

volatile unsigned char TIM2_CR2; /* control register 2 */

volatile unsigned char TIM2_CR1; /* control register 1 */

volatile unsigned char TIM2_SR; /* status register */

volatile unsigned char TIM2_IC1H; /* input capture 1 high */

volatile unsigned char TIM2_IC1L; /* input capture 1 low */

volatile unsigned char TIM2_OC1H; /* output compare 1 high */

volatile unsigned char TIM2_OC1L; /* output compare 1 low */

volatile unsigned char TIM2_CNT; /* counter high */

volatile unsigned char TIM2_CNTL; /* counter low */

volatile unsigned char TIM2_ACH; /* alternate counter high */

volatile unsigned char TIM2_ACL; /* alternate counter low */

volatile unsigned char TIM2_IC2H; /* input capture 2 high */

volatile unsigned char TIM2_IC2L; /* input capture 2 low */

volatile unsigned char TIM2_OC2H; /* output compare 2 high */

volatile unsigned char TIM2_OC2L; /* output compare 2 low */

*.prm

TIMA INTO NO_INIT 0x0031 TO 0x003F;

TIMB INTO NO_INIT 0x0041 TO 0x004F;

why appear the result.

attachments is the file ,thank you.

________________

Attachments :

test.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzW5&d=%2Fa%2F0X0000000bUc%2FLfhMNe8vPtXuZhEUG9BuKjzGXx7izCdVRupU1c5rvIo&asPdf=false
juhee
Associate II
Posted on August 10, 2004 at 11:49

In *.prm file in ''NAMES'' section where you give the names of the files to be linked.

For register map file st72321.o use a '+' sign after that

for example

NAMES main.o

st7231.o+

timer.o

ansi.lib

END

This will avoid the optimization of register MAP file. Otherwise compiler removes the variables (registers in this case), which are not used.

hzcoffee
Associate II
Posted on August 11, 2004 at 13:29

thank you sir,i have do it.

check map file fint it wrong.

thank you help.