> I still can't get it running. Karl showed me the way to understand > the docu - at least I felt like understanding it... > Current code status: > > //testing PWM4 > PINSEL0 |= 0x20000; // select pin 0.08 PWM4 function > > PWM_PR = 0x0000; // max prescale counter value > PWM_MCR = 0x0002; // reset TC when PWMMR0 matches > PWM_PCR = 0x7E00; // enable all PWM just to get the right one > PWM_TCR = 0x000A; // reset TC counter (not yet needed?!) > > PWM_MR0 = 0x0400; // match register 0 trigger value > PWM_LER |= BIT0; > > PWM_MR4 = 0x0150; // match register 4 trigger value > PWM_LER |= BIT4; > > PWM_TCR = 0x0009; // set the TC counter and enable the PWMs > > But still getting the single 88.64 ms pulse. > Any idea? > > Cheers, Kurt. Hi Kurt, I think the main problem is that you have to wait until you get the Match _before_ the PWM cycle is actually written. This would explain why you only get a single pulse. Follow this procedure I use : /* Setting the PWM cycle */ /*******************/ PWMTCR = 0x0B; // Hold TC in reset while altering Cycle PWMMR0 = CYCLE; // Write the new PWM period PWMMCR = 0x01; // Allow the INT flag for MR0 PWMTCR = 0x09; // Restart PWM PWMIR |= 0x01; // Reset MR0 Int flag PWMLER = 0x01; // Enable PWM0 latch while ( ! (PWMIR & 0x01)); // Wait for match -> new cycle complete PWMMCR = 0; // Disable MR0 Int flagging /* Setting , for example, PWM5 */ /***********************/ PWMMR5 = DUTY; // write duty cycle PWMLER = 0x20; // enable PWM5 Latch Obviously CYCLE is the total PWM cycle and PERIOD makes the PWM's dutycycle as = DUTY / CYCLE So if you eg. set CYCLE to 1000 and DUTY to 150 you would get a 15% dutycycle with a frequency of PCLK / 1000 (cycle), providing Prescaler is set to ONE (=0). There might be better ways of doing this, but this way ensures you wait long enough for the PWM period cycle to update, but no longer than necessary...... B rgds and good luck, Kris [Non-text portions of this message have been removed]
Message
Re: [lpc2000] Re: PWM with olimex lpc2106-mt pcb - how to?
2004-07-21 by microbit
Attachments
- No local attachments were found for this message.