Wixel and PWM

I looked at your PWM code for Timer 1.

Why do you think T1CC1 will have any effect?

It looks like you configured your timer badly because you set it up so that T1CC0 controls the high time of the pulse (because you configured it to be in output compare mode) but it also controls the frequency (because that’s how modulo mode works). This doesn’t make sense and I think it will just result in your line being high or low all the time. You need to instead configure channel 1 to be your PWM output so that T1CC0 sets the frequency and T1CC1 sets the pulse width. If this doesn’t make sense, read the datasheet carefully.

–David

I was looking at Figure 33: Output Compare Modes, Timer Modulo Mode and the Output Compare Mode 4 signal. If I’m setting T1CCTL0 for output compare mode 4, why does this diagram not apply to it? It looks like T1CC0 is setting the frequency and T1CCn (T1CC1 or T1CC2?) is setting the pulse width…

In your code you never configured Timer 1 Channel 1 to be in output compare mode, so T1CC1 doesn’t control anything.

Figure 33 explains what happens when you set a channel to be in output compare mode while the timer itself is in modulo mode (frequency controlled by T1CC0). The channel that is in output compare mode is then named “n” for the purpose of the diagram. Since you incorrectly set channel 0 to be in output compare mode, n is 0, so T1CCn is the same as T1CC0. The diagram might still apply, but not in the way you think it does.

Section 12.6.5 is helpful.

–David

wow, thank you for clarifying that! One more question: does this mean it isn’t possible to output a PWM signal on P1_2 because it is Timer 1 Channel 0? If I set T1CC1 to modify the duty cycle, does that mean the whole PWM signal is being output on Timer 1 Channel 1?

If you’re constraining yourself to use modulo mode, then the answers are both yes. You can get a PWM output on P1_2 if you use free-running mode. That’s one of the things that the new servo library in the Wixel SDK does.

The only advantage of using modulo mode over free-running mode is that you get more control over the frequency/period. Your prescaler options in T1CTL are 1,8,32, and 128 so if you are in free-running mode (where the counter always counts up to 2^16-1) that lets you have these periods:

2^16 / (24 MHz) = 2.73 ms
2^16 * 8 / (24 MHz) = 21.86 ms <-- ideal for servos
2^16 * 32 / (24 MHz) = 87.38 ms
2^16 * 128 / (24 MHz) = 349.53 ms

So if you still want to control your servo from P1_2 using your own PWM code you should be able to do that with free-running mode.

–David

Hello, sheepcounter.

I tracked down the bug in GNU Make that was giving you trouble earlier, and released a new, fixed version. It’s in the latest Wixel Development Bundle, so you can get it by downloading the bundle and choosing to install the Pololu GNU Build Utilities. Once you have the new version (3.82-pololu2), you don’t have to comment out important lines from the Makefile any more.

–David

Hi everybody,

I’m new to micro-controller and electronic, but coding is my work.
I initialiy plan a project using Arduino with Wixel as wireless device.
But I quickly realize that the Wixel can do it alone.

What I want to do is just dimming and switching on/off lights remotly.

I’m only missing the PWM part, so I download the wixel-pwm timer lib.

I just try to make the test_timer app works.

If I understand correctly the code, it set the alternate timer 1 output channel 1 (P1_1) in hardware PWM mode.
So I connect a led on the P1_1 output of the wixel and start the programme.
But the led stay off all the time.

I connect the + of the led to the P1_1 via a 330 ohms resistor, and the - of the led to the GND of Wixel.

I add a debug output to the USB/Serial to print the ledValue variable content.
And it looks good the variable alternate from 32 to 224.

Did I miss something ?

Thank’s for you help.

Constant

Hello, Constant. I believe the app you downloaded is not part of the official Wixel SDK. You might have better luck contacting the person who made it. If you are going to ask about it here, you should at least post a link to the source code. If you have not already, I recommend that you take a look CC2511F32 datasheet in the “Resources” tab on the Wixel’s product page because it will tell you how the timers work and how to configure them to make PWM signals:

pololu.com/catalog/product/1337/resources

–David

Hello David,

Sorry my message wasn’t clear enought, you are right to code is not coming from the offical Wixel SDK, I get the code from dpark83 at
github.com/dpark83/wixel-pwm but it wasn’t update for 2 years, so I guess code is old.

This fork of your SDK contain an app called timer_test.c (github.com/dpark83/wixel-pwm/bl … st_timer.c) this is the app I was talking about in my first post.

But I have a clue, I use the code in the first post (Wixel and PWM) of this thread, and the led light on very low, I increase the duty cycle and the led light get brigther, I guess the initial duty cycle is to low. Or my resistor is to strong.

I’m reading the CC2511F32 datasheet, and try to get how timer/PWM is working.

Thank’s and regards,

Constant

I am glad you were able to get PWM working. Let me know if you have more questions. --David

Thank’s

Constant