EmbeddedRelated.com
Forums

PWM Conflicts with ADC on LPC2148

Started by "Ben...@yahoo.com [lpc2000]" December 5, 2014
I am using the LPC2148 with a 12MHz crystal using a 5 multiplier to have 60MHz CCLK. PCLK running at same frequency as CCLK. I had some working software triggered ADC code. When I added a PWM output with a match interrupt, the ADC always returns 0 (the PWM output is working correctly) I can't figure out why this is happening. Any help would be appreciated
Here is a link to the PastBin for the code:[C] LPC2148 PWM confilicts with ADC - Pastebin.com
|   |
|   | |   |   |   |   |   |
| [C] LPC2148 PWM confilicts with ADC - Pastebin.comvoid InitADC(void) {     PINSEL1 |= (1<<28); // Select AD0.3 for P0.30 }   int GetADCResult(void) {     int result = 0;             // Perform ADC acquire and conve... |
| |
| View on pastebin.com | Preview by Yahoo |
| |
|   |

An Engineer's Guide to the LPC2100 Series

Line 38

> PINSEL1 = (1 << 10); // Select PWM5 output for P0.21

Should be read-modify-write. Something like this:
PINSEL1 = (PINSEL1 & ~(0x03<<10)) | (0x01 << 10);