MobaTools - trying to add attiny 3226 support #1223
Replies: 1 comment
|
The TCA on the tiny3226 is, very nearly identical to that on the mega0. I just diffed the I/O headers, Only difference between the mega0's TCA and tiny2's TCA is that EVACT bitfield was renamed EVACTA, and the second event action was added, along with the matching CNTEI renamed to CNTAEI. The TCA proper is otherwise identical Obviously the pins are different, but there are no new registers or anything. All those other registers were there, presumably unused. And, obviously tiny PORTMUX is not the same as non-tiny PORTMUX (though all non-tiny parts are now using the same pinning, and the tinies are almost identically pinned with each other (the exception being the 8-pin parts) The CTRLF registers are the stupid rigamarole they came up with to let you set or clear bits without having to do a read-modify-write, which would need to be done with interrupts disabled to prevent a race condition. These are implemented similarly to the PORTx.OUTSET/OUTCLR registers - both of them should read as the value of the CTRLF bits (which are the BV flags that, along with LUPD in the other register, allow you a considerable measure of control over when an UPDATE (copying of buffered values into the registers being used to generate the PWM. Only relevant if using the *BUF registers to prevent PWM glitches as they discuss in the datasheet (a considerable portion of the chapter is, in some manner, about buffering and it's use for preventing PWM glitches. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I'm making an attempt at getting MobaTools to work with an attiny 3226.
Orig code: https://github.com/MicroBahner/MobaTools
My fork: https://github.com/Cobalt6700/MobaTools/tree/attiny_3226
I understand this may be a question for the author of MobaTools, however I figured I would ask here about timer specifics first. I would also like to state that I am a hobbyist trying to wrap my head around how timers work and are used.
I'm having a problem with getting the timers setup right. MobaTools uses TCA0 CMP1 register for timing of the servo pulses.
I copied over the timers setup from the megaavr section of the library and have tried to re-write for use with megatinycore. I did some reading up on the timers and, as far as I understand, I'm on the right track, but I don't seem to be able to get a servo output when using tackoverTCA0().
Here is the megaavr timer code, taken from https://github.com/Cobalt6700/MobaTools/blob/attiny_3226/src/megaAVR/MoToMegaAVR.cpp
I originally didn't use takeOverTCA0() in my code so I'm guessing changing the registers didn't actually do anything to the timer (as indicated in the megatinycore docs).
I can get servos to work like this (this feels like luck) however the position resolution the servos is greatly reduced and, well, a bit crap really (I'm suspecting even less than the 4us/tic stated).
I have since updated and tried a few different things, however now the servos don't move at all. I have also tried calling this code in the setup of my sketch, that didn't work either. To confirm, this is called when servo.attach() is called, so it should be in the setup phase anyway.
Any advice greatly appreciated :)
All reactions