Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

PWM output

2006-02-24 by Herbert Demmel

Hi,

I seem to miss something with setting up PWM5 output - the routine below 
sometimes works, sometimes not (depending non additional code - this 
versions below currentlly does NOT work).

Any idea what I miss to setup?

Thanks for your input.

Regards
Herbert

#include <LPC213x.H>                    /* LPC213x definitions  */

#define TICKS_PER_US            15

void io_alarm_out(unsigned int freq)
{
         // match register 0 controls the cycle frequency
         PWMMR0 = 1000000 * TICKS_PER_US / freq;

         // we want to have a duty cycle of 50% so always set PWMMR5 to 
half of PWMMR0
         PWMMR5 = PWMMR0 / 2;

         // enable PWM5 output
         PWMPCR |= (0x01 << 13);
}

int main(void)
{
         // --- PWM5 setup ---

         // Enable P0.21 to be PWM5
         PINSEL1 |= (0x01 << 10);
         PWMTCR = 1;             // enable PWM timer, let shadow register 
disabled

         // reset PWM timer when PWMMR0 matches
         PWMMCR = 0x2;

         // gives 1000Hz
         io_alarm_out(1000);

         while (1)
                 ;
}


----------------------------------------------------------
demmel products
Radnitzkygasse 43
A-1100 Vienna / Austria / Europe
Voice: +43-1-6894700-0
Fax: +43-1-6894700-40
Email: dh@...
WWW: http://www.demmel.com

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.