At 07:19 AM 7/25/2005, koorosh wrote:
>hi again
>
>but how can i use counter for 1000,you know ,i could get only 1
>milisecond from 8 bit counter.and how can i make it with 16 bit
>counter?
>can you write the codes? what would you do if you have to make 1
>second for a digital clock?
I use a 1mS interrupt to count out through weeks in one application.
Set an intermediate counter to increment once a millisecond, and then
every hundred mS, increment at tenths of seconds counter.
Every time that hits 10, increment the seconds counter, and so on.
When you increment the next counter, zero this one:
In this example, I had a timer interrupt that happened every 5mS
;We get here every 5mS
Int_HMS:
lds TEMP,HMS ;Hundred millisec
dec TEMP ;
sts HMS,TEMP ;
and TEMP,TEMP ;Return if not zero
breq Int_HMS_Done ;
ret
Int_HMS_Done:
ldi TEMP,20 ;Reload the 100mS (20*5 = 100) counter
sts HMS,TEMP ;
;We get here, every 1/10th second
lds TEMP,Tenths ;
dec TEMP ;
sts Tenths,TEMP ;
and TEMP,TEMP ;
breq Int_HMS_Done ;
ret
Int_Secs_Done:
ldi TEMP,10 ;
sts Tenths,TEMP ;
lds TEMP,Seconds ;
;And so on...Message
Re: [AVR-Chat] Re: please help me!
2005-07-26 by Dave VanHorn
Attachments
- No local attachments were found for this message.