10 years, 5 months ago.

PwmOut in LPC800

Hi, Why I can't compile code:

#include "mbed.h"
#include <PwmOut.h>

PwmOut led(LED1);

int main() { }

Error is:

"Identifier "PwmOut" is undefined" in file "/main.cpp", Line: 4, Col: 1

I'm newbie in LPC and ARM platform, I just got my LPC812-MAX mbed/Xpresso board and I want to use PWM on built-in LED (or external).

Also, how I can check if built-in button is pressed? Example uses I2C, it's little complicated...

I have the same problem...

posted by Marcin Kosela 07 Oct 2013

2 Answers

10 years, 5 months ago.

Sadly the LPC800 has no PwmOut options. I don't know if it can't make them at all, or it is just that its timer(s) are already used for ticker/timeout/etc and that it has no other timers.

But on NXP page, in specifications, value for Nperi (for PWM) is 4...

posted by Jan Szenborn 07 Oct 2013

Thats a very good question. My answer came from the source code which has PwmOut disabled (I don't have the board myself currently).

A quick check makes me think they use the SCT for the timer functions, which also is the only thing that can make PWM. The mbed site doesn't tell it can use PWM, although the pin picture does show it, which I think then is incorrect. (I also don't understand why there are those pin limitations, okay a few I get, but I thought the LPC800 could switch pin functions around with barely limitations).

posted by Erik - 07 Oct 2013

I can understand this problem for something this new. But given that my robot has to be finished in the next 7 days, it's crippling my progress and definitely a bad decision on my part to migrate from the arduino :( hopefully someone can fix this asap

posted by Ian Hua 09 Oct 2013

If it needs to be done in the next 7 days then that is indeed a problem. Especially since that also doesn't leave much time for alternatives. There is the KL25Z which also has the arduino formfactor and the seeeduino with the LPC11U24, and they both have PWM. Or if you don't need the formfactor you can use any mbed enabled device.

If you don't need timer functions you can also try to manually set registers to use PWM. I really wouldn't expect this to be fixed within 7 days, since it is designed to be like this.

Edit: Checked alternative timers to use for timing functions, but they lack prescalers, so not really many alternatives.

posted by Erik - 09 Oct 2013

For now I've resorted to using a software-type PWM. I only need to change some servo angles (for my camera mount), so it's not too much of a disaster for now. It just means I cant use PWM to efficiently drive my motor drivers, still gonna have to rely on arduino

posted by Ian Hua 13 Oct 2013
10 years, 5 months ago.

See the LPC800-MAX RGB demo using PWM State-Configurable Timer (SCT),

Import programlpc800-max-RGB

LPC800-MAX RGB demo using SCT and MRT

http://www.lpcware.com/content/nxpfile/lpc80-sct-cookbook-and-tutorial-code-examples