Jan, > I think some where in amForth TCNT1 is overwritten!
Indeed. Every time timer1 overflows. > When I change some of the preload value by hand no change is seeing. > Frequency is staying at 15,2 Hz. Yes. You are seeing a frequency of 16000000 divided by 8 (for the prescaler) divided by 65536 (for each rollover of the timer1) divided by 2 (for the LED toggle) which gives a theoretical 15.3Hz , close to your observed value. Are you looking to generate something for multiplexing a display? There might be an easier way, if that is the case. Best wishes, Tristan On 02Nov18 20:09, Jan Kromhout wrote: > Hi, > > I have taken the TIMER_1 example, and make some small change. > Instead of the timer1.tick I toggle pin-7 of the Arduino. > With the values as in the listing I measure a frequency of 15,2 Hz with my > scoop. > > When I change some of the preload value by hand no change is seeing. > Frequency is staying at 15,2 Hz. > > When I print the value of TCNT1 after setting, and compare this one after > timer1.start there is a difference > > First value = 63536 and the Second value = 31033. > > I think some where in amForth TCNT1 is overwritten! > > Please can you take a look. > > I included my program. > > Cheers, > > Jan > > \ TIMER1_interrupt > > marker --timer1_interrupt-- > > PORTD 7 portpin: PD7 > PD7 pin_output > > &26 constant TIMER1_OVFAddr > > : togglePD7 > PD7 pin_high? if PD7 low else PD7 high then > ; > > : timer1.isr > \ toggle output PD7 > togglePD7 > ; > > \ preload for overflow interrupt every 1 ms > \ preload = 65536 - (f_cpu / (prescaler * 1000)) > > : timer1.preload > f_cpu #1000 um/mod nip 8 / negate \ <===== if i change the value #1000 > notting is change > ; > > : timer1.init ( -- ) > timer1.preload TCNT1 ! > TCNT1 @ u. cr \ <=============== print value of TCNT1 =========== > ['] timer1.isr TIMER1_OVFAddr int! > ; > > : timer1.start > -int > timer1.init > %00000010 TCCR1B c! \ prescaler 8 > %00000001 TIMSK1 c! \ enable overflow interrupt > +int > ; > > : timer1.stop > %00000000 TCCR1B c! \ stop timer > %00000000 TIMSK1 c! \ stop interrupt > ; > > > > _______________________________________________ > Amforth-devel mailing list for http://amforth.sf.net/ > Amforth-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/amforth-devel > _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel