cancel
Showing results for 
Search instead for 
Did you mean: 

TBU timer problem

top3971
Associate II
Posted on October 02, 2003 at 08:15

TBU timer problem

3 REPLIES 3
top3971
Associate II
Posted on October 02, 2003 at 05:17

hi! all

I have some problems about TBU timer...

it's my function.

pragma TRAP_PROC SAVE_REG

void timer1()

{

//unsigned char i;

//unsigned char key_temp;

//unsigned char key_temp1;

// timer decrement

//if(ValBit(TBUCSR, 5))

// {

if(t_hdd)

t_hdd--;

// }

if(t_fan)

t_fan--;

if(t_audio)

t_audio--;

if(t_printer)

t_printer--;

if(t_cd)

t_cd--;

if(t_ad)

t_ad--;

if(t_adint)

t_adint--;

// time base 1sec

if(tb_100ms)

tb_100ms--;

else

{

tb_100ms = 10;

if(t_disp)

t_disp--;

}

// time base 1sec

if(tb_1sec)

tb_1sec--;

else

{

tb_1sec = 100;

t_1sec++;

}

// key input chattering routine

//unsigned char keytemp;

//unsigned char keytemp1;

sela(0);

selb(1);

key_temp = PBDR;

asm ld A, PBDR

asm ld key_temp, A

key_temp = PBDR;

//key_temp = key_temp & 0x01;

asm LD A, key_temp

asm AND A,0x01

asm LD key_temp,A

key_temp = key_temp << 2;

key_temp1 = key_temp;

sela(1);

selb(0);

//key_temp = PBDR;

asm ld A, PBDR

asm ld key_temp, A

//key_temp = key_temp & 0x01;

asm LD A, key_temp

asm AND A,0x01

asm LD key_temp,A

key_temp = key_temp << 1;

key_temp1 = key_temp1 + key_temp;

sela(0);

selb(0);

//key_temp = PBDR;

asm ld A, PBDR

asm ld key_temp, A

//key_temp = key_temp & 0x01;

asm LD A, key_temp

asm AND A,0x01

asm LD key_temp,A

key_temp1 = key_temp1 | key_temp;

i = key_temp1;

//i = _pa;

//i &= 0x07;

// || ((_pc & 0x0

<< 1) & 0x10);

if(i == key_buffer)

{

if(key_count)

key_count--;

else

{

key_data = i;

key_count = 6;

}

}

else

{

key_buffer = i;

key_count = 6;

}

}

I set timer1's vector in prm file, and set TBUCSR, and TBUCV register,

I have questions now...

1)Interrupt was not enable without ''asm RIM'' instruction why? is it another way to enable inturrupt?

2)this function steps at debugging mode. when function is over, it is back to first of function ''if(t_hdd)'' everytime Idon't know why. can I fix it?

[ This message was edited by: JayB on 02-10-2003 08:48 ]

jatin
Associate II
Posted on October 02, 2003 at 06:30

1.) RIM is an global interrupt enable instruction . You can not have the timer interrupt without enabling the global interrupt bit.

2.) Try to run it continuosly. It returns again to the the function due to the pending interrupt.
top3971
Associate II
Posted on October 02, 2003 at 08:15

thanks for your help!

I don't want to be back to timer function every time... I want to be

back in period time, I set tbu registers, but It returns every time.

how can I do?