cancel
Showing results for 
Search instead for 
Did you mean: 

About inerrupt by 16bit-timer...

vega
Associate II
Posted on July 24, 2006 at 06:27

About inerrupt by 16bit-timer...

1 REPLY 1
vega
Associate II
Posted on July 24, 2006 at 06:27

#include ''ST7lib_config.h''

int i=0;

void main(void);

void main(void)

{

unsigned int OCR_VALUE = 0x4e20;

IO_Init();

TIMERA_Init (TIMER_FCPU_8);

IO_Output (IO_PUSH_PULL,IO_PORT_A,((unsigned char)IO_PIN_0|((unsigned char)IO_PIN_1|((unsigned char)IO_PIN_2|((unsigned char)IO_PIN_3|((unsigned char)IO_PIN_4|((unsigned char)IO_PIN_5|((unsigned char)IO_PIN_6|((unsigned char)IO_PIN_7)))))))));

EnableInterrupts

TIMERA_IT_Enable(TIMER_OCMP_IT_ENABLE);

PADR=0x01;

TIMERA_OCMP_Mode(TIMER_OCMP_2,OCR_VALUE,TIMER_OUTPUT_R);

while(1);

}

#ifdef _HIWARE_ /* test for HIWARE Compiler */

#pragma TRAP_PROC SAVE_REGS /* additional registers will be saved */

#else

#ifdef _COSMIC_ /* test for Cosmic Compiler */

@interrupt /* Cosmic interrupt handling */

#else

#error''Unsupported Compiler!'' /* Compiler Defines not found! */

#endif

#endif

void TIMERA_IT_Routine(void)

{

unsigned char t,t2;

t = TAACR;

t2=TACR;

i=i+1;

if (i==100)

{

PADR=PADR<

i=0;

}

TIMERA_Clear_Flag(TIMER_FLAG_OCF2);

TAACR=0x00;

}

-----------------------------------------------------------------------

That is my code and it can work.

My problem is that when the value of OCR_VALUE smaller then 0x8000,it can exit the subroutine,but when the value biger than 0x8000 the program which can't exit the subroutine becomes a loop.

Because I am a beginner on ST7,so I don't know how to do.

Can anyone tell me that why the value can't biger then 0x8000?

Thank you for your help...