Attiny1616 -> TMRB Repeated event when interrupt not cleared?

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I have a conundrum to verify. I've three comparator signals; one is for reset, one for over-voltage and one for under-voltage.

 

If over-voltage = 1 in LUT0 it sets the CCL sequential gate (RS) as high.

 

If under-voltage = 0 AND a reset falling edge is detected it sets LUT1 high and the RS becomes low.

 

The potential issue is while a LUT has an edge detector it's not on each input but on the combined logic, so the RS could be cleared at the wrong time (timing is critical, it must be on the reset edge). Thus I don't believe I can use the LUT edge detect.

 

The same reset signal is being piped into TMRB0 which I'm measuring in frequency mode (with edge detection set to the falling edge). I've found TMRB can be piped into LUT thereby replacing the direct comparator signal, and since it should fire an event at nigh on the same time

 

I think it'll do what I'm after. My question is whether the event will fire if I don't have the requisite TMRB interrupt enabled (i.e once the interrupt flag is set) and whether it'll repeatedly fire if the flag isn't cleared?

 

I should mention the signal is no more than about 200Hz, so if necessary I could easily clear the interrupt flag for TMRB in software to allow the next event to fire - but I'd rather keep the whole approach to a 100% hardware based solution if possible.

 

Cheers

Last Edited: Mon. Oct 12, 2020 - 08:40 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, the datasheet says the event output of TCB is a one cycle pulse, not exactly a mirror of the interrupt flag.

 

edit:

This pulse just happens to be generated by the same conditions that set the flag.

 

My conclusion is that some experimentation will be needed. Normally, in these situations, I direct the event I want to investigate to an event output, so that I can observe it with a scope/logic analyser.

Last Edited: Mon. Oct 12, 2020 - 11:01 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It also says it's fired when the interrupt flag is set, but not whether it's repeatedly fired.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See my edit above, if the datasheet is not 100% clear, research will be needed.

 

edit: BTW, when you say this

snoopy33 wrote:

 I've found TMRB can be piped into LUT

 

You mean connecting a LUT input to timer B directly, or routing the event output of timer B to the LUT via event system?

Because these are different things, TCB output (the one you can connect directly to the LUT) is changed only by single-shot and PWM modes, it's not the same thing as the event output that we have been discussing.

Last Edited: Mon. Oct 12, 2020 - 11:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry I meant via the event system. I didn't realise TCB output could be fed into LUT directly.

 

I'll test properly over the next few days. From my initial testing TMRB will capture continuously with INT off, which makes sense as sometimes the user will want it running and to take the latest read when ready in software, such as a task based. From this I'm hoping it also sends the CLK period to the event system even when INT is disabled.

 

I would've used the second TMRB with the same input as a monostable to create the edge but it's occupied with another timing matter.

 

Thanks!

 

Last Edited: Mon. Oct 12, 2020 - 09:48 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Short answer, it works. :)

Key is applying the SYNC FILTER in the LUT 

Last Edited: Tue. Oct 13, 2020 - 01:40 PM