Page 1 of 1

Timer usage

Posted: Fri Oct 10, 2014 12:38 am
by nelfata
Hello,
I am trying to use the timer functionality on Y11/B0 and I don't seem to get it to work as on other pins.

t = pyb.Timer(1, freq=1000, mode=pyb.Timer.CENTER)
ch2 = t.channel(2, pyb.Timer.PWM, pin=pyb.Pin.board.Y11, pulse_width=(t.period() + 1) // 2)

The datasheet shows: PB0: TIM1_CH2N, TIM3_CH3, TIM8_CH2N
I think there is some configuration issue with inverted timer channels (TIM1_CH2N).

Did someone try this on Y11?

Re: Timer usage

Posted: Fri Oct 10, 2014 1:23 am
by dhylands
I've never tried the inverted channels. There is probably some additional setup that needs to be done.

Yeah - I see that there are separate functions in the HAL for turning out complimentary Output Compare and PWM modes.

Re: Timer usage

Posted: Fri Oct 10, 2014 1:32 am
by nelfata
Do you think this could be an easy fix?
If not please let me know. Thanks.

Re: Timer usage

Posted: Fri Oct 10, 2014 8:12 am
by dhylands
I've got something coded up and it seems to be working. It needs some more testing.

Re: Timer usage

Posted: Fri Oct 10, 2014 12:25 pm
by nelfata
ok great. I will be waiting for your changes. Thank you.

Re: Timer usage

Posted: Fri Oct 10, 2014 5:09 pm
by dhylands
I created https://github.com/micropython/micropython/pull/900 if you want to try it out before it gets merged.

Re: Timer usage

Posted: Sat Oct 11, 2014 8:00 pm
by dhylands
Now merged.

Re: Timer usage

Posted: Sat Oct 11, 2014 8:37 pm
by nelfata
Excellent. Thanks.

Re: Timer usage

Posted: Sat Oct 11, 2014 10:46 pm
by nelfata
Tested. Works great.