Re: [Flashforth-devel] Microsecond counter problem, please help
Brought to you by:
oh2aun
From: Mikael N. <mik...@fl...> - 2021-10-31 11:40:53
|
László, Just to show you an example of how to scale and format numbers I added printing of the time in microseconds. In idle mode you can see that the measured time is always the same because the execution of TIMERTEST is in sync with the millisecond interrupt. In busy mode the execution time varies with 1 milliseconds depending on the phase relationship of the TIMERTEST command and the millisecond timer0. idle hex ok<$,ram> timertest counter: 18781d time: 100225.812 us ok<$,ram> timertest counter: 18781d time: 100225.812 us ok<$,ram> busy hex ok<$,ram> timertest counter: 18a140 time: 100884.0 us decimal ok<#,ram> timertest counter: 1601046 time: 100065.375 us BR Mikael On 2021-10-30 20:46, Stefan wrote: > Did you check the word 'load'? If it exists, Timer1 is used by the > system-load-counter. For other purposes TCNT1 is 'read only' then. > You could use 'us' (from the 'avr/forth'-subdirectory) to wait for a > specified number of microseconds. > > If Timer1 is free for use -> see timertest.fs > > greetz bitflipser > > > Am 30.10.2021 um 04:59 schrieb Mikael Nordman: >> You have the wrong interrupt vector number. >> >> #14 constant TIMER1_OVF_vect >> >> BR Mikael >> >> On 2021-10-29 14:05, Laszlo Kollar wrote: >>> I am newbie in forth and especially MCUs >>> I would like to ask for help. >>> I would like to write a driver for DHT-22 humidity/thermo sensor. It >>> needs measure microsecond resolution changes in pin state, so I wrote >>> a >>> small code in order to count microseconds based on this article: >>> https://www.reddit.com/r/arduino/comments/1q1chr/using_timer1_to_count_clock_cycles/ >>> >>> >>> I try to implement it but failed in several various ways. >>> once it looks like stuck in a infinity reset, sometimes no prompt >>> after >>> running, sometimes flood garbage when use 'words' after running the >>> code. >>> >>> What mistake I made in this code? >>> Please help me! >>> >>> Thanks in advance! >>> >>> László Kollár >>> >>> _______________________________________________ >>> Flashforth-devel mailing list >>> Fla...@li... >>> https://lists.sourceforge.net/lists/listinfo/flashforth-devel >> > > > _______________________________________________ > Flashforth-devel mailing list > Fla...@li... > https://lists.sourceforge.net/lists/listinfo/flashforth-devel -- -- Mikael |