TCB0 Interrupts #957
Replies: 5 comments 4 replies
-
And just as I posted this I tried something and got it working - my TCB_CNTRLA_ON_8MHZ and TCB_CNTRLA_ON_4MHZ bit settings are wrong. If I set it to TCB_CNTRLA_ON_8MHZ then it suddenly starts working. |
Beta Was this translation helpful? Give feedback.
-
Does it make any difference if you add
at the end of setup? I am just curious that you apparently don't need to do that. |
Beta Was this translation helpful? Give feedback.
-
I am confused what you try to accomplish here.
Or do you mean B00000101 where you type 0x101 ? The hexadecimal value 0x101 equates to the binary value 100000001 (decimal 257), which is bigger than the 8bit register you cast it into. You are also setting the TCB0.CTRLA register twice during setup, so the second time you overwrite what you set the first time. |
Beta Was this translation helpful? Give feedback.
-
This is probably what you want
|
Beta Was this translation helpful? Give feedback.
-
Soundsl ike this is mostly sorted? Do also note - if you're ever printing values and you want to get hexadecimal, you can pass a number to Serial.printHex() and Serial.printHexln() to get it printed out as hex. Depending on the datatype you pass it, it will pad it with zeros as appropriate. For datatypes larger than a byte, there's an optional second argument to swap the endianness too if you're getting bytes printed in the reverse of the order you want :-) It's documented with all the other extensions to the Serial API in https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/Ref_Serial.md (I've exposed damned near every feature except 9-bit mode (too much overhead for people not using it), lin-constrained autobaud (because cars are life-safety critical and Arduino is not an appropriately rated for such applications; since the only application of LIN is in automotive stuff, supporting that mode would amount to encouraging unsafe operation that could endanger the user and those around them) and IRDA pulse encoding mode (didn't IRDA die decades ago?). We do support putting it into IRDA mode to use event input theoretically - it's never been tested AFAIK (and you have to do the event routing still. But, I think that this can remap rx to any pin, (and you can remap TX to any CCL output by using CCL.LUTnCTRLB = 0x08 and TRUTHn = 0x02 for USART0 (0x80 and 0x04 for USART1) assuming 2-series - I think the number is different on 1-series). And yeeah I think everything else the hardware can do is exposed through the API and I made it take up less space - though the effect is not visible on tiny0/1 on tiny2, the difference is small (it gets larger for each USART present - they had a copy of the ISR for each serial port, and the ISRs are not the smallest things around (though they're as small as I could get them as hand optimized assembly now) - and instead of having up to 6 identical USART ISRs, the ISR itself is declared as a naked, used function so it goes in if serial is used at all, but the thing pointed to by the vector? That's just a stub - it pushes a register or two so it can load a pointer to the USART struct, then rjmps to the single copy of the ISR which is tightly hand optimized, and which works around the errata impacting inconsistent sync field detection and the SFDEN bug too (you have to turn off SFDEN before reading the received data). The second RS232 mode (the one that they removed - at least on paper) where XDIR acts as an input, and control;s whether TX is enabled, has not been tested either. I suspect the reason it was dropped was because it didn't work all that well. It raises a bunch of paradoxes about how the chip should behave under corner cases, and thinking about it, I couldn't decide which one was less wrong. But you basically got a menu of bad options |
Beta Was this translation helpful? Give feedback.
-
I'm new to the whole tiny AVR thing so I thought I would ask if I am doing something wrong in my code.
I am trying to use TCB0 to generate a periodic interrupt. I've got it configured and running, but the ISR doesn't seem to ever get called. Have I misunderstood what I am supposed to be doing here?
Beta Was this translation helpful? Give feedback.
All reactions