Forum: ARM programming with GCC/GNU tools No Signal on PWM5

Author: Stephan Weiss (weiss)
Posted on:

Rate this post
0 useful
not useful
Dear all

I am using an LPC2138 uController and I'm trying to set up 4 PWM signals
while still having the ports for serial communication (TXD0, RXD0) Hence
the choice
fell on PWM2, PWM4, PWM5, PWM6.

PWM2,4,6 worked fine first, only PWM5 did not show any signal. Later
(one fine day) PWM4 went out as well. PWM2 and 6 work perfectly as they

1) I measured the outputs directly at the uController's pins, so bad
connections on the board should not be the problem (except pin is pulled
to ground...I'll check that)
2) I configured PWM4 and 5 as GPIO and put a 1 to them -> I measured 0V!
3) I configured PWM6 as GPIO and put a 1 to it -> I measured 3.3V

Program code:

  /* init PLL, MAM etc. */

  uart0Init(UART_BAUD(BAUD), UART_8N1, UART_FIFO_8);

  /* Enable pin 0.0 TXD0; pin 0.1 RXD0; pin 0.7 as PWM2; pin 0.8 as
PWM4; pin 0.9 PWM6*/
  PINSEL0 = 0x000A8005;

  /*Enable pin 0.21 as PWM5*/
  PINSEL1 = 0x00000400;

        /*Tests with gpio/*
        //PINSEL0 = 0x88005;  //set pwm4 as gpio
        //PINSEL0 = 0x28005;  //set pwm6 as gpio
        //PINSEL1 = 0x0; //set pwm5 as gpio
        //IODIR0 = 0x200000;  //set direction as output of according pin
        //IOSET0 = 0x200000;  // set level to 1 of according pin

  /* Load prescaler on x ticks
   * Here: 3B bei 4*14,7456MHz, Aufloesung auf ca 1us */
  PWMPR  = 0x0000003B;

  /* PWM channel 2,4,5,6 single edge control, output enable */
  PWMPCR = 0x00007400;

  /* On match with timer reset the counter */
  PWMMCR = 0x00000002;

  /* Set cycle rate to x ticks,
  /*here 3ms at 4*14.7...MHz and resolution of 1us*/
  PWMMR0 = 0x00000BB8;

  /* Set of PWM2 to x ticks,

  /* Enable shadow latch for match 0-1 */
  PWMLER = 0x00000075;

  /* Enable counter and PWM, release counter from reset */
  PWMTCR = 0x0000000B;
  PWMTCR = 0x00000009;

     while(1)              //from here on main while loop


Possible causes:
- uController pins of PWM4 and PWM5 broken but works correctly with the
- Register values wrong??

Many thanks in advance!!


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.