cmonr / Embedded-Software

A Repo for all of the Embedded Software I create
AnomalousMaker.com
2 stars 1 forks source link

PWM peripherals share one clock #2

Closed cmonr closed 10 years ago

cmonr commented 10 years ago

Motor PWM peripheral is clocked at the same frequency as the Servo PWM peripheral.

Unfortunately, the PWM Capture Compare and Reload registers are only 16 bits wide, which means that a motor freq of 25KHz and servo freq of 50Hz won't work well together.

cmonr commented 10 years ago

Will likely have to change the Motor frequency to 1KHz and deal with it.

cmonr commented 10 years ago

getSystemClock -> getDesiredFrequencies -> find divisor that will fit in 16 bits, but with max resolution

cmonr commented 10 years ago

80 MHZ [1KHz, 50Hz] Clock divisor of 8 Reload values: [312.5, 6250]

fdominguezr commented 10 years ago

Hi cmonr!

Thanks for sharing.

In your PWM code you say "Works! Using a Tiva launchpad instead of a Stellaris Launchpad helps..." Do you know why is not working in Stellaris? Thanks!

Francisco

cmonr commented 10 years ago

The Stellaris Launchpad uses an MCU that doesn't have the PWM peripherals that I'm using on the Tiva Launchpad.

fdominguezr commented 10 years ago

Thanks cmonr for your fast answer!

I'm checking the PWM function in the Tiva™ C Series TM4C123G LaunchPad Evaluation Board (EK-TM4C123GXL): http://www.ti.com/tool/ek-tm4c123gxl

But I can't make it work. It has 4 PWM modules and 12 PWM outputs. Is it similar to the board you used? I would like to re-use your code if possible. Thanks!

cmonr commented 10 years ago

If it says Tiva Launchpad in between the buttons, then this code will work. Unfortunately, I haven't necessarily been keeping up with what code still works since I've changed how some of my libraries function.

Which project were you referring to?

fdominguezr commented 10 years ago

Hi Cruz,

BTW Do you speak Spanish?

The code I'm talking about is this: https://github.com/cmonr/Embedded-Software/blob/951093f2bc8651adb291092a368f99d6d0c8dff4/TI/tm4c123gh6pm/HOALib%20PWM/src/main.c

I think I mixed up two programming concepts: one with Keil where all function addresses are mapped in one file, and the other with several .h header files with definitions about addresses. Now that I have that clear, I have to short out how to handle the PWM functions in the Tiva board...

Saludos,

Francisco http://www.franciscodominguez.es http://twitter.com/franciscodr http://about.me/francisco.dominguez

This message may contain confidential information that is protected by professional privilege or whose disclosure is prohibited by law. If you are not the addressee indicated in this message, please delete it and notify us immediately. Please do not forward it or copy its content. If your company does not allow receipt of this type of message, please inform us immediately.

2014-05-19 7:41 GMT+02:00 Cruz Monrreal II notifications@github.com:

If it says Tiva Launchpad in between the buttons, then this code will work. Unfortunately, I haven't necessarily been keeping up with what code still works since I've changed how some of my libraries function.

Which project were you referring to?

Reply to this email directly or view it on GitHubhttps://github.com/cmonr/Embedded-Software/issues/2#issuecomment-43467613 .

theotherjimmy commented 10 years ago

Just a quick heads up: Cruz and I both use GCC, OpenOCD, and make on Arch Linux to build and debug this code. We have made no efforts to port it to use another toolchain. With Keil your milage may vary.

If that was not clear, I'll put it in the readme. On May 19, 2014 4:45 PM, "fdominguezr" notifications@github.com wrote:

Hi Cruz,

BTW Do you speak Spanish?

The code I'm talking about is this:

https://github.com/cmonr/Embedded-Software/blob/951093f2bc8651adb291092a368f99d6d0c8dff4/TI/tm4c123gh6pm/HOALib%20PWM/src/main.c

I think I mixed up two programming concepts: one with Keil where all function addresses are mapped in one file, and the other with several .h header files with definitions about addresses. Now that I have that clear, I have to short out how to handle the PWM functions in the Tiva board...

Saludos,

Francisco Domínguez Román Past-Presidente 2009 Joven Cámara de Empresarios Barcelona

http://www.franciscodominguez.es http://twitter.com/franciscodr http://about.me/francisco.dominguez Móvil: 690 084 326

  • Antes de imprimir este mensaje, asegúrese que es necesario. El medio ambiente está en nuestra mano.Please evaluate if you need a paper copy of this mail before printing it. We are all concerned by the protection of the Environment.

This message may contain confidential information that is protected by professional privilege or whose disclosure is prohibited by law. If you are not the addressee indicated in this message, please delete it and notify us immediately. Please do not forward it or copy its content. If your company does not allow receipt of this type of message, please inform us immediately.

2014-05-19 7:41 GMT+02:00 Cruz Monrreal II notifications@github.com:

If it says Tiva Launchpad in between the buttons, then this code will work. Unfortunately, I haven't necessarily been keeping up with what code still works since I've changed how some of my libraries function.

Which project were you referring to?

Reply to this email directly or view it on GitHub< https://github.com/cmonr/Embedded-Software/issues/2#issuecomment-43467613>

.

— Reply to this email directly or view it on GitHubhttps://github.com/cmonr/Embedded-Software/issues/2#issuecomment-43562574 .

cmonr commented 10 years ago

@fdominguezr, because this is all development code, I haven't been diligent about documenting it thoroughly.

To reiterate what @theotherjimmy mentioned, as of right now, the code is only verified to work in my and @theotherjimmy's particular configuration: Arch Linux, OpenOCD, and GCC.

That particular piece of code will fade in and out the Red LED.

You should also know that the chip on the Tiva Launchpad has much more PWM generators than the Stellaris Launchpad. The 12 PWM modules that you quoted are actually being generated from the Timers, whereas on the Tiva Launchpad there's an additional 16 PWM generators separate from the Timers that that particular example makes use of.

fdominguezr commented 10 years ago

Hi Jimmy and Cmor,

Thanks for your fast answer! Yes, Tiva Launchpad is more powerful for PWM and other tasks, and that was one reason to get it... Well as I see you developed your solution in a very different environment. As I'm in contact too with people that develop in Keil, I'll pursue the solution with them. You can follow my updates here: http://letsmakerobots.com/content/lets-learn-basics-robotics-edxs-embedded-systems-shape-world Also in my Twitter: http://twitter.com/franciscodr

Thank you very much! Francisco