That is a pretty wide range ie 100000:1 which won't be directly possible with 16-bit (65535:1) timers. But you could split it into two ranges, say 0.1 to 32 Hz and 32 Hz to 10,000 Hz, and so if we deal with the lower range first:The frequencies are variable starting at 0,1 Hz and ending at 10000 Hz.
There are three 16-bit timers, and I would be surprised if the operating environment used all three of them, and did not leave any free for application use.That means all timers except timer 0 are working?
This is a pessimism-free forum.I thought that this will not run.
I agree. The calculations are straightforward, although you might want to consider doing them with integer arithmetic rather than floating-point.If so there is a way cause I can calculate the timer prescaler and the ocra value.
No. No problem. Refer pessimism note above.There is a problem with the 16 bit timers
Section 19.3 "Accessing 16-bit Timer/Counter Registers" on page 159 of the datasheet is one step ahead of you.I have to split 16bit ocr value in 2 Bytes (high and low) ich I understood correct.
The whole beauty of using the timer compare output and reset features is that timer interrupts are not required. Interrupts = heartache. Avoid if possible.But can I use the timer Interrupts within using B4R?
I agree it is still an "if" until we see it working. I have done this on another microcontroller with similar timer capabilities; here I am working off the datasheet, and trusting that the designers are designing hardware to help their customers (eg you and me) solve common problems (eg generating PWM signal).If this would run
you and me bothI would be really, really happy with this
or, because we're just setting registers, no interrupts required, I would expect B4X code to be similarly basiccause I can write the timers in inline C (#if c)
No idea what this means. Setting up the timer should just be a case of setting registers to values. Adding objects sounds like over-complication to me.and set my variables as objects so thet I can send them to the cpu.
No idea what this means. No interrupts required to generate this frequency signal - the resetting of the timer count by OCRxA compare does the job for us. Section 19.9.2 "Clear Timer on Compare Match (CTC) Mode" on page 168 of the datasheet describes this heartache-reducing feature.But what is when CPU is doing a timer interrupt with my B4R Code