Right to it - can you / how do you get megaTinyCore to use TCB0 in place of TCA0 for the ATtiny1604 part?
I am using part ATtiny1604 (OK, what did I know when I purchased them?).
I want to use the megaTinyCore Arduino wrapper (A big thanks here to Dr Azzy).
I want to use millis() (Another big thanks here to Dr Azzy).
I want to have a clock speed capable of sending TTY serial debug.
And here’s the rub - I want to control a servo with a 50Hz PWM signal.
By default, millis() uses the TCA0 counter on this part - and a fine 16 bit counter it is too.
I tried to use TCB0 on this part to generate PWM signal but this ‘16 bit counter’ has the period controlled by the lower 8 bits of CCMP and the duty cycle by the higher 8 bits .
In terms of slowing things down, you only get to select CLK_PER/DIV2.
With a system clock running at 16MHz which is good for Arduino serial.print(), the slowest servo frequency I can get is 160kHz plus.
If I select the 32kHz for the system clock, I can achieve a PWM signal for my servo at 50Hz but this ‘tanks’ the Serial.print() functionality of megaTinyCore.
OK, I can (and have) set up TCB0 to generate a tidy 1kHz interrupt and increment a ‘tick counter’ to replace millis() but I was wondering if anyone knows if you can define something to get megaTinyCore to use TCB0 instead so I can use the ‘full fat’ 16 bit TCA0 counter for my 50Hz PWM servo signal?
BTW - I simply loved the Historical section in the doc https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/Ref_Tuning.md
especially the bit about the guy getting bitten by the (watch)dog - it happened to me and bricked an AVR in the process.
I appreciate ‘yall’ want code to pick through but what’s the point in posting code that I know doesn’t work? I’m just chasing concepts here.
Can you help?