ATTiny1607 TCB0 does not trigger on events.

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

It looks like I found another hw bug in the ATtiny1607.

The timer module TCB0 seems to not respond to events from the event system. Our setup is AC0 -> Async Channel 0 -> TCB0 in One Shot  mode. The intended purpose is, that on each edge from the comparator output, there shall be one pulse on PC0.

Here is the setup:

// Event System. Only AC0 -> TCB0 ist used. EVOUT1 only for debugging.
void evsys_init(void)
    {
    EVSYS_ASYNCCH0 = EVSYS_ASYNCCH0_AC0_OUT_gc;
    EVSYS_ASYNCUSER0 = EVSYS_ASYNCUSER0_ASYNCCH0_gc;
    //! \todo  Debugging only, shows that the events are working
    EVSYS_ASYNCUSER9 = EVSYS_ASYNCUSER9_ASYNCCH0_gc;
    PORTMUX_CTRLA = PORTMUX_EVOUT1_bm;
    }

// Triac trigger pulse
void timerB_init(void)
    {
    TCB0.CTRLA = 0; // stopped
    TCB0.CTRLB = TCB_CNTMODE_SINGLE_gc | TCB_CCMPEN_bm;
    TCB0.EVCTRL = TCB_FILTER_bm | TCB_EDGE_bm;
    TCB0.INTCTRL = TCB_CAPT_bm;
    TCB0.INTFLAGS = TCB_CAPT_bm; // Clear IF
    TCB0.DBGCTRL = 0;
    TCB0.CNT = TRIG_PULSE_WIDTH; //  prevent premature trigger
    TCB0.CCMP = TRIG_PULSE_WIDTH; // 270µs trigger pulse
    PORTMUX_CTRLD = PORTMUX_TCB0_bm; // set output to PC0
    TCB0.CTRLA = TCB_ENABLE_bm;
    }

The events are running, EVOUT1 pin toggles as expected.

Maybe there is something wrong with the initialization?

 

For now we have implemented a workaround by setting TCB0.CNT = 0 in the AC0 ISR, which triggers the output pulse.
 

This topic has a solution.
Last Edited: Tue. Nov 19, 2019 - 12:44 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
TCB0.EVCTRL = TCB_FILTER_bm | TCB_EDGE_bm;

Maybe you should also enable CAPTEI.

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

Thanks, this helped.

The bit CAPTEI is just named misleading.  The datasheet says ' Bit 0 – CAPTEI Capture Event Input Enable. Writing this bit to '1' enables the input capture event.'. Actually, it enables triggering by the event system.

The datasheet ( DS40002030B) has some more timeconsuming flaws and inaccuracies, it urgently needs a review.

 

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

hpvoelpel wrote:
The datasheet ( DS40002030B) has some more timeconsuming flaws and inaccuracies, it urgently needs a review.

 

You should have seen the original datasheet for the tiny412... even pin assignments were incorrect. Lengthy discussion here: https://www.avrfreaks.net/forum/...

Fortunately, probably after lots of complaining, it was corrected.

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

>The bit CAPTEI is just named misleading

 

75% of the description makes sense in every case- 'Event Input Enable', 4 out of 6 of the modes that use the events have 'Capture' in their name, and it happens to be in the EVCTRL register. The datasheet in 21.3.4 (titled Events) also spells out that the bit has to be set to 1 to enable event inputs.

 

I'm giving the point to Atmelchip in this case.