AnsweredAssumed Answered

pwm on the lpc1115 via om13087 board

Question asked by Justin Sconza on Dec 25, 2017
Latest reply on Dec 26, 2017 by Justin Sconza

I'm struggling to get PWM working on this board.  I'm using lpcxpresso and my code is below.  My goal is to have the blue LED on pin 28 of the board to blink along with the PWM signal (50% duty cycle so a basic square wave). And I want to use the pointer style syntax.

 

 

#include "LPC11xx.h"

int main(void) {

 

   // set up pin for PWM use (sec 7.4.23)
   LPC_IOCON->PIO0_9 &= ~(0x3FF);
   LPC_IOCON->PIO0_9 |= 0x2;

 

   // enable clock signal to 16 bit timer0 (sec 3.5.14)
   LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7);

 

   LPC_TMR16B0->PR          = 12000-1;
   LPC_TMR16B0->MR3       = 1000;
   LPC_TMR16B0->MR0       = 500;
   LPC_TMR16B0->MCR       = (1<<10);          // Reset on MR3 Match
   LPC_TMR16B0->PWMC    = 0b1010;         // set channel 0 and 1 to PWM mode (sec 18.7.12)
   LPC_TMR16B0->TCR         |= (0x3);            // Enable & Reset Timer
   LPC_TMR16B0->TCR         &= ~(0x2);       // Clear Reset Bit

 

   while(1){
   }

   return 0;

}

Outcomes