Hi everyone,
I have a trouble when programing the timer. here is the code. I'll very gratefull.
void SetBusCLK_16M(void)
{
CPMUOSC_OSCE=1; //enable oscillator
CPMUCLKS_PLLSEL=0; // disable PLL
CPMUREFDIV=0x41; //Fref=Fosc/(1+1)=4M
CPMUSYNR=0x03; // Fvco=2*Fref*(1+3)=32M
CPMUPOSTDIV=0x00; // Fpll=Fvco/0+1 =32M,Fbus=16M
_asm(nop);
_asm(nop);
_asm(nop);
_asm(nop);
while(CPMUFLG_LOCK == 0);
while(CPMUCLKS_PLLSEL==0);
CPMUPROT=0x00;
}
void initialize_ect(void)
{
TSCR1_TFFCA = 1;
TSCR1_TEN = 1;
TIOS = 0xFF;
TCTL4 = 0x00;
TIE = 0x01; //enable channel 0 interrupt
TSCR2 = 0x87;
TFLG1 = 0xff;
TFLG2 = 0xff; }
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 16_Vtimovf (void) // this interrupt enty is ok
{
if(TFLG2_TOF ==1)
{
temp=TCNT;
dd = ~dd; //for LED sparking per second
}
}
#pragma CODE_SEG DEFAULT
/*************************************************************/
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 8_Vtimch0 (void)// This interrupt entry is wrong. WHY?
{
TFLG1_C0F = 1;
TC0 = TCNT +125;
ZZ=~ZZ; //for out put a wave at one I/O.
}
#pragma CODE_SEG DEFAULT