Hi, Thanks all for the suggestions. After reload the timer after every interrupt it is working great.
My leaving question is the word “f_cpu” in the code of Timer1.frt. When I execute it I get two values on the stack. What is the meaning of this two values? Cheers, Jan Op 3 nov. 2018, om 12:31 heeft Richard Burden <richard.burden.pe...@gmail.com<mailto:richard.burden.pe...@gmail.com>> het volgende geschreven: Hi Jan I suggest that the ISR has to toggle the pin and re-load the timer1 counter. From memory timer1 counts upwards and once it overflows it just keeps counting up from zero unless you re-load it. Regards Richard On 11/3/18, Jan Kromhout <krom1...@hotmail.com<mailto:krom1...@hotmail.com>> 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<mailto: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<mailto: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