Replies: 3 comments 4 replies
-
Wait, I'm looking at that code... Euhm... you have the TCB disabled! It's not going to do anything like that.... (the general formula for configuring any peripheral on a modern AVR is disable it if it's enabled, set up everything else, then finish by clearing the INTFLAGS just in case one is set somehow, then finally set ctrla. Be sure to set count to top because of what they say about single-shot mode:
I know nothing about DALI so I'm not entirely sure what you need to do, but with the way the EDGE bit now works ( and which they finally updated the datasheet to account for) one setting is "Rising edge" and the other is "rising or falling edge" But you want "falling edge"? Man it's too bad these parts don't have a way to invert a pin input.... Oh wait, they do! Set the INVEN bit in PINnCTRL either manually or through our pinConfigure function (see Ref_Digital.md); That inverting is the first thing that happens as it comes in, before events and shit. So that gives you an easy way to turn the falling edges that you can't specify as a TCB event trigger into rising ones which you can. And nope, no restriction on when event channels are configured, you can do it at runtime |
Beta Was this translation helpful? Give feedback.
-
Ah, well my suggestion of inverting the pin still holds for the one that's
triggering on a rising edge or falling edge - invert the pin and set to
start timer on rising edge (meaning falling edge since inverted
…____________
Spence Konde
Azzy’S Electronics
New products! Check them out at tindie.com/stores/DrAzzy
GitHub: github.com/SpenceKonde
ATTinyCore: Arduino support for almost every ATTiny microcontroller
Contact: ***@***.***
On Wed, Mar 15, 2023, 19:10 dr-rockzo ***@***.***> wrote:
SpenceKonde,
Thanks for replying, i really appreciate how much work you've put into
this and how willing you are to help. Please let me clarify what I'm trying
to do.
So basically DALI is a 16 bit packet, Manchester encoded serial used to
control LED drivers (it's like slow DMX). To decode it, i need to trigger
the one-shot which delays 625uS (3/4 of the 1200bd period), then read the
pin input pin.
I do have the timer enabled, it happens in the last little chunk of
setup() and i know the setup works because, it sets the "debugLED" pin high
when the timer starts via the pin interrupt and sets the pin low when the
timer ISR fires in the top code i posted.
The top code "works" timing wise, but Event0 starts firing on the first
rising edge. I need to ignore the first rising edge of the packet and start
the Event/TCB on the first falling edge. So i wrote the second piece of
code where i tried to activate Event0 in an ISR trigger by the rising edge
of the signal, detaching that interrupt so as not to disturb Event0, then
after the packet is received the pin ISR is re attached. The problem is the
when i try that, the timer ISR never gets triggered by Event0; i can tell
that because only the timer ISR turns off DebugLED and it stays on.
I don't think that activating Event0 from the ISR is working, but I'm also
not sure if it should. I'll post a timing diagram tomorrow to make the
issue more clear if that would help.
—
Reply to this email directly, view it on GitHub
<#417 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTXEW2WBELW2FIMWAGSAMTW4JD4ZANCNFSM6AAAAAAV4NF6W4>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Alright, I got it firing on the right edge for the first packet but for some reason it's like the event and timer don't reset. I know the code is getting to where that should happen because, the flag for a new packet gets set and it sends the packet over serial. It's almost like Event0 is not stopping. I used pinConfigure to invert the pin and set the pin ISR to RISING. I feel like I'm overlooking something.
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a project where I'm trying to decode a 1200 baud, manchester encoded signal (DALI - Digitally Addressable Lighting Interface) and am trying to use the Event System and TCB0 to decode it. Basically the Event System triggers TCB0 in "single shot" mode, then when it gets to TOP, an ISR runs which reads the input pin and writes a bit to a variable. I have it almost working but cannot for the life of me get it to trigger on the right edge. I need to synchronize to the first falling edge (this is what I can't get working) and then fire the timer every time the pin changes (this part is working).
I thought I would use a FALLING interrupt on the pin to enable the Event0 channel, but that doesn't seem to work because the timer never fires (not on time or later than expected). So my question is, can the Event channels be started and stopped outside of Setup and if so are there any special considerations? I have attached the "almost working" code and "not working" code; please be gentle, I am by no means an expert.
This is the code that sort of works, but synchronizes to the wrong edge (first rising edge):
This is the code I thought would let me line up on the first falling edge, but it appears Event0 never fires the timer:
Beta Was this translation helpful? Give feedback.
All reactions