Page 1 of 1
LPC11u37 and HWPWM
Posted: Mon Feb 05, 2018 3:45 am
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
Re: LPC11u37 and HWPWM
Posted: Mon Feb 05, 2018 9:33 pm
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.
Re: LPC11u37 and HWPWM
Posted: Tue Feb 06, 2018 12:06 am
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.
Re: LPC11u37 and HWPWM
Posted: Tue Feb 06, 2018 3:28 pm
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
Re: LPC11u37 and HWPWM
Posted: Tue Feb 06, 2018 7:43 pm
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.
Re: LPC11u37 and HWPWM
Posted: Wed Feb 07, 2018 1:38 pm
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
Re: LPC11u37 and HWPWM
Posted: Wed Feb 07, 2018 5:46 pm
by nik282000
Thanks, I hope to be able to share more complete works later. I'm glad you found my code helpful.
Re: LPC11u37 and HWPWM
Posted: Mon Feb 12, 2018 6:11 pm
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
Re: LPC11u37 and HWPWM
Posted: Mon Feb 12, 2018 6:18 pm
by basicchip
OK phpBB3 not allowing me to add multiple files
here is a zip of those files
Re: LPC11u37 and HWPWM
Posted: Thu Feb 15, 2018 5:16 pm
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!