From: pito <pi...@vo...> - 2010-08-08 19:26:27
|
Hi, thanks to Matthias the anycrystal clock works! However, I can observe an interesting phenomenon I do not understand: 1. when I fresh flash atmega and upload the clock: \ count clock 1 second ticks from timer2 overflows: \ any crystal clock 2variable ticker 2variable seconds 262144. 2constant clkpi 1. 2constant d_one1 0. seconds 2! 1. ticker 2! decimal \ overflow2 interupt service routine \ increment tick : tick_isr ticker 2@ clkpi d- ticker 2! ticker 2@ clkpi d< if f_cpu ticker 2@ d+ ticker 2! seconds 2@ d_one1 d+ seconds 2! then ; hex \ enable ticks : +ticks 7 TCCR2 c! ( 111 = f_cpu clock/1024 ) 0 ASSR c! ( source: internal clock = f_cpu) ['] tick_isr TIMER2_OVFAddr int! ( register interupt ) TIMSK c@ 40 or TIMSK c! ( enable timer2 interupt ) ; \ disable ticks : -ticks TIMSK c@ [ 40 invert ff and ] literal and TIMSK c! ( clr Timer 2 ) ; decimal 2. then after first usage of +ticks the second increments by 10 - the clock tick is 10HZ, so the inerrupt runs 10x faster, or something like that !!??!! 3. when I unmark the clock routine and upload it again (no change in code, no flashing of atmega) the clock works fine - 1 second tick, increment by one per second. Any idea? Pito. |