G30TH Timer trouble

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

G30TH Timer trouble

Post by jgriessen » Tue Aug 09, 2016 9:49 pm

I've looked up how to do register writes using names in the stm module.
I changed my dual pulser program to use register writes to initialize the output compare pin's HIGH state,
and left the pyb.Timer.OC_INACTIVE compare in there, but no go. It's as if the HIGH state is not being set.

Oh wait! I think I know why.. I set a pin high in a callback that never gets called!
Adding some more init stuff...

Hmmm..... there is no CCMR3 defined in the stmhal/cmsis/devinc/stm32f401xe.h file.
Maybe this is for library size reasons...

Rewriting to use different timer numbers....
John Griessen blog.kitmatic.com

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

Re: G30TH Timer trouble

Post by dhylands » Tue Aug 09, 2016 11:07 pm

CCMR3? I'm not seeing that defined anywhere?

There are only 4 channels for any of the timers on the 40x chips, and each CCMRx register covers 2 channels, so there will only be CCMR1 (for channels 1 & 2) and CCMR2 (for channels 3 & 4)

User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: G30TH Timer trouble

Post by jgriessen » Wed Aug 10, 2016 1:33 am

Well I am caught out as a newbie at STM32F's and python too!
John Griessen blog.kitmatic.com

User avatar
jgriessen
Posts: 191
Joined: Mon Sep 29, 2014 4:20 pm
Contact:

Re: G30TH Timer trouble

Post by jgriessen » Wed Aug 10, 2016 9:02 pm

Thanks for pointing out that mistake about CCMR1, CCMR2 registers.
What I think I can use now after trying stuff and reading a lot, is called frozen mode where the timer output pin does not change, then go back to PWM mode 1 when I want an output again. That's how I will get my desired PWM outputs that alternate half cycles, and everything will change symmetrically when I change the compare number with a micropython method such as
t2ch2.pulse_width(950)
t2ch3.pulse_width(950)
The pulses will be exactly the same, since the number change happened between times, not near a compare match, and the pulse width times do not depend on interrupts, the interrupts depend on the times.
I'll do that pulse_width() number changing in the interrupt callback. Not confirmed yet, but close...
John Griessen blog.kitmatic.com

Post Reply