LPC11u37 and HWPWM

Questions about the BASICtools and MakeItC
Post Reply
nik282000
Posts: 10
Joined: Sat Jan 20, 2018 10:53 pm

LPC11u37 and HWPWM

Post by nik282000 »

I've been plugging away with my LPC11u37 and I haven't been able to get the HWPWM (HWPWM11) library to work. The code below compiles just fine but when the chip runs the program, pin 8 (channel 1) sits at about +3mV with some very high frequency, low amplitude noise. I have tried all 4 channels/pins and had the same result on multiple boards so I don't think it is something I am doing. If anyone has had PWM work on their 11u37 board I would like to heard about it, I'm still not 100% convinced that it's not something that I've done or not done.

-Thanks

Code: Select all

#include <HWPWM11.bas>
MAIN:
FOR i=0 TO 100 STEP 1
	HWPWM(1,1000,500)
	PRINT i
	WAIT(1000)
	HWPWM(1,1000,100)
	WAIT(1000)
NEXT i
END



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: LPC11u37 and HWPWM

Post by basicchip »

This code was written for the LPC1114.

We are checking to see if we need to move any pins for the LPC11U37, as the parts are not identical.

nik282000
Posts: 10
Joined: Sat Jan 20, 2018 10:53 pm

Re: LPC11u37 and HWPWM

Post by nik282000 »

Ah, thanks I saw the following in the HWPWM11 and thought I could use it.

Code: Select all

#if defined LPC1114
#elif defined LPC11U37
#else
  #error this version of HWPWM11.bas is only for the LPC1114 or LPC11U37
#endif
In the mean time, I have been able to software pwm enough pins for my current project with reasonable success.

olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: LPC11u37 and HWPWM

Post by olzeke51 »

Can you share briefly what you did??
What frequency were you trying to output -- I would like to have some sound for my DICE-r project.
Still working on the pcb-layout with KiCad. -- learning curve!
Thanks for listening - Gary

nik282000
Posts: 10
Joined: Sat Jan 20, 2018 10:53 pm

Re: LPC11u37 and HWPWM

Post by nik282000 »

Hi, you'll have to take this with a small moon's worth of salt because I was just hacking things together to drive an RGB LED. The following code may work for audio but you will have to adjust the PWM cycle time and the "step time" to suit your needs. Because this is all done in software the PWM cant be run all the time, you have to call it and keep calling it for however long you want the output to last. This is my first stab at uContollers, I apologise for the mess.
Attachments
SWPWM_demo.bas
(2.28 KiB) Downloaded 461 times

olzeke51
Posts: 414
Joined: Sat May 17, 2014 4:22 pm
Location: South Carolina

Re: LPC11u37 and HWPWM

Post by olzeke51 »

Welcome aboard @nik282000 !!
We all start somewhere and sometime.
'
Good looking doc - the ascii waveform will help us all - learning or refresher!
And thanks for sharing.
'
My sound / buzzer is for short bursts - so it will only run occasionally - GETS your attention-type.
'
Have a good day, Gary Olzeke

nik282000
Posts: 10
Joined: Sat Jan 20, 2018 10:53 pm

Re: LPC11u37 and HWPWM

Post by nik282000 »

Thanks, I hope to be able to share more complete works later. I'm glad you found my code helpful.

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: LPC11u37 and HWPWM

Post by basicchip »

We updated the HWMPW.bas library for LPC11U37

copy these to /Program Files (x86)/Coridium/BASIClib
- HWMPW.bas
- HWPWM11.bas
- LPC11U3x.bas

and a very simple test program
- HWPWMtest.bas

I know one of the complaints about ARM is their user manuals can be up to 1000 pages long. While that is true, you really don't have to read all those pages. For instance the counter-timers are pretty simple and only 20 or so pages long. The meat of the discussion in the NXP pages is found at the beginning of the chapter which describes what is required to use that peripheral.

For PWM, you need to enable the clock to the counters you are using -- SYSCON_SYSAHBCLKCTRL has a bit for each peripheral
Enable the pin for timer MATCH output

Then set 1 timer for the cycle time and have it reset all counters
For each PWM set the compare where the output will change state (needs to be less than cycle time)
Then enable the counter

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: LPC11u37 and HWPWM

Post by basicchip »

OK phpBB3 not allowing me to add multiple files

here is a zip of those files
HWPWM.zip
(10.91 KiB) Downloaded 823 times

nik282000
Posts: 10
Joined: Sat Jan 20, 2018 10:53 pm

Re: LPC11u37 and HWPWM

Post by nik282000 »

Thank you! I appreciate your support, I have never worked with hardware at this level so I am lost even after comparing a c++ implementation of PWM on the 11u37 to the nxp manual and the existing libraries. I'll give the new ones a a go this evening.

Thanks again!

Post Reply