Timer usage

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Timer usage

Post by nelfata » Fri Oct 10, 2014 12:38 am

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?

User avatar
dhylands
Posts: 3214
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Timer usage

Post by dhylands » Fri Oct 10, 2014 1:23 am

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.

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: Timer usage

Post by nelfata » Fri Oct 10, 2014 1:32 am

Do you think this could be an easy fix?
If not please let me know. Thanks.

User avatar
dhylands
Posts: 3214
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Timer usage

Post by dhylands » Fri Oct 10, 2014 8:12 am

I've got something coded up and it seems to be working. It needs some more testing.

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: Timer usage

Post by nelfata » Fri Oct 10, 2014 12:25 pm

ok great. I will be waiting for your changes. Thank you.

User avatar
dhylands
Posts: 3214
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Timer usage

Post by dhylands » Fri Oct 10, 2014 5:09 pm

I created https://github.com/micropython/micropython/pull/900 if you want to try it out before it gets merged.

User avatar
dhylands
Posts: 3214
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Timer usage

Post by dhylands » Sat Oct 11, 2014 8:00 pm

Now merged.

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: Timer usage

Post by nelfata » Sat Oct 11, 2014 8:37 pm

Excellent. Thanks.

nelfata
Posts: 74
Joined: Wed Apr 30, 2014 10:50 pm

Re: Timer usage

Post by nelfata » Sat Oct 11, 2014 10:46 pm

Tested. Works great.

Post Reply