Reply by "rst...@pacbell.net [lpc2000]"●December 6, 20142014-12-06
That's fine, there is no reason not to use it. Except that unless the work
is directly related to the PWM, it might be better to do it in a Timer
interrupt. For certain, no PWM calculations need to be done in an interrupt.
Reply by "ben...@yahoo.com [lpc2000]"●December 6, 20142014-12-06
Thanks for the link, I will take a look.
I plan to use the ISR to do some work down the road, so I do need it.
Reply by "rst...@pacbell.net [lpc2000]"●December 6, 20142014-12-06
Probably the best sample code around for the LPC2148 is at
LPC2148 Demo Code Overview http://www.jcwren.com/arm
LPC2148 Demo Code Overview http://www.jcwren.com/arm The latest demo code
version is 1.44, dated 12-Jan-2009 View the latest README file Download the
latest tar+gzip'ed version (Linux) Download the latest zipped version
(Windows)
Among other things, there is no need for an interrupt handler to create PWM and
it usually isn't necessary to reconfigure the ADC just to start a
conversion.
Read over JC's code and see if it helps.
Richard
Reply by "ben...@yahoo.com [lpc2000]"●December 5, 20142014-12-05
Please ignore this. I posted here and thought it got cancelled, so I sent an
email with the same problem.
Reply by "ben...@yahoo.com [lpc2000]"●December 5, 20142014-12-05
I am writing some code for the LPC2148. I have some working ADC code using AD0.3
on P0.30. After adding PWM using PWM5 on P0.21 with match interrupts, the ADC
always returns 0. I have been unable to determine why. Any help would be
appreciated. Here is the code for each:
// PWM Interrupt is an IRQ interrupt so clear bit
VICIntSelect &= ~(1 << 8);
// Set PWM interrupt to slot 0 and enable slot
VICVectCntl0 = (1<<5) | 8;
// Set the address of ISR for slot 0
VICVectAddr0 = (unsigned) PWM_ISR;
// ---- PLL0 has been setup with CCLK 60Mhz and PCLK also = 60Mhz.
// === Configure P0.21 for Output as PWM5 ============= // Period: 4 ms
// Duty Cycle: 12.5%
// Pulse duration: 0.5 ms
// ----------------
PINSEL1 = (1 << 10); // Select PWM5 output for P0.21
PWMPCR = 0x0; // Select Single Edge PWM
PWMPR = PWM_PRESCALE-1; // 1 micro-second resolution
PWMMR0 = 400; // 400 ticks i.e 400*1us = 4ms period duration
PWMMR5 = 50; // 0.5 ms Initial pulse duration i.e width
PWMMCR = (1<<1) | (1<<0) // Reset PWMTC and interrupt on PWMMR0 match
| (1<<15); // interrupt on PWMMR5 match
PWMLER = (1<<0) | (1<<5); // update MR0 and MR5
PWMPCR = (1<<13); // Enable PWM output for PWM5
PWMTCR = (1<<1) ; //Reset PWM Timer and Prescale counters
// Enable
PWMTCR = (1<<0) | (1<<3); // enable counters and PWM Mode output
}
void PWM_ISR(void)
{
long regVal = PWMIR;
// Check PWM Interrupt Register to determine which match
// generated the interrupt.
if (PWMIR & (1<<0)) // PMMMR0 match - beginning of period
{
// Do X
}
else if (PWMIR & (1<<9)) // PWMMR4 match - beginning of pulse
{
// Do Y
}