Sign in

username:

password:



Not a member?

Search lpc2000



Search tips

Subscribe to lpc2000



lpc2000 by Keywords

2106 | ADC | ARM7 | Atmel | Bootloader | CAN | CrossStudio | CrossWorks | DDS | ECos | Ethernet | ETM | FIFO | FLASH | FPGA | GCC | GDB | GNU | GNUARM | GPIO | I2C | IAP | IAR | JTAG | Kickstart | LCD | Linux | LPC | LPC-E2294 | LPC2000 | LPC2100 | LPC2104 | Lpc2106 | Lpc210x | LPC2114 | LPC2119 | LPC2124 | LPC2129 | Lpc2138 | LPC213x | LPC21xx | LPC2210 | LPC2212 | LPC2214 | LPC2292 | LPC2294 | LPC2xxx | LPC3128 | MCB2100 | Olimex | Philips | PWM | Rowley | RTC | RTOS | SPI | SSP | UART | UART0 | UART1 | ULINK | USB | Watchdog | Wiggler

Ads

Discussion Groups

Discussion Groups | LPC2000 | Using PWM on an LPC2101

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

Using PWM on an LPC2101 - rfkd07 - Jul 29 8:32:22 2008

Hey there,

unfortunately I have quite some troubles when trying to use PWM on
pin P0.8 (MAT2.1) of my LPC2101 controller (without the use of
interrupts). The following code is what I have until now:

// Configure P0.8
PINSEL0 &= ~(3<<16);
PINSEL0 |= 2<<16;

T2TCR = 1<<1; // Reset TC and PC, disable timer
T2PR = 5; // Prescaling
T2MCR = 1<<10; // Reset on MR3 match
PWM0CON = 1<<3; // Use single edged PWM for MR3
T2EMR = 1<<1 | 3<<6; // Enable MAT2.1 and set toggle mode

// Setup PWM parameters
unsigned short cycles = 49152;
T2MR3 = cycles; // Period duration
T2MR1 = cycles/4; // Pulse width
T2TCR = 1<<0; // Enable counter

Prescaling and the value of the 'cycles' variable are computed
depending on the frequency, the values above are just examples for
F=200Hz (PCLK=58,982,400Hz). My problem is that the pulse remains
constantly high for 5ms, then constantly low for 5ms. Seems like MR1
is getting ignored. Any help available? Thanks in advance.

-rfkd07
------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )


Re: Using PWM on an LPC2101 - wvanhoomissen - Jul 30 0:53:29 2008

A couple things to check:
PLL multipler (make sure ur clock speed is what you think)
Peripheral clock divider (R U dividing main clock by 2?)

--- In l...@yahoogroups.com, "rfkd07" wrote:
>
> Hey there,
>
> unfortunately I have quite some troubles when trying to use PWM on
> pin P0.8 (MAT2.1) of my LPC2101 controller (without the use of
> interrupts). The following code is what I have until now:
>
> // Configure P0.8
> PINSEL0 &= ~(3<<16);
> PINSEL0 |= 2<<16;
>
> T2TCR = 1<<1; // Reset TC and PC, disable timer
> T2PR = 5; // Prescaling
> T2MCR = 1<<10; // Reset on MR3 match
> PWM0CON = 1<<3; // Use single edged PWM for MR3
> T2EMR = 1<<1 | 3<<6; // Enable MAT2.1 and set toggle mode
>
> // Setup PWM parameters
> unsigned short cycles = 49152;
> T2MR3 = cycles; // Period duration
> T2MR1 = cycles/4; // Pulse width
> T2TCR = 1<<0; // Enable counter
>
> Prescaling and the value of the 'cycles' variable are computed
> depending on the frequency, the values above are just examples for
> F=200Hz (PCLK=58,982,400Hz). My problem is that the pulse remains
> constantly high for 5ms, then constantly low for 5ms. Seems like MR1
> is getting ignored. Any help available? Thanks in advance.
>
> -rfkd07
>

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

Re: Using PWM on an LPC2101 - rfkd07 - Jul 30 1:12:41 2008

Thanks for your reply. The PLL is fine I think and my PCLK is running
at the same speed as CCLK (~58 MHz). System ticks based software
timers work perfectly so I think the problem must be somewhere else.
Any other ideas?
--- In l...@yahoogroups.com, "wvanhoomissen" wrote:
>
> A couple things to check:
> PLL multipler (make sure ur clock speed is what you think)
> Peripheral clock divider (R U dividing main clock by 2?)
>

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

Re: Using PWM on an LPC2101 - ksdoubleshooter - Jul 30 12:25:44 2008

Remove the line setting up T2EMR and set up the RIGHT bit in the
RIGHT PWMCON register.

Jeff

--- In l...@yahoogroups.com, "rfkd07" wrote:
>
> Hey there,
>
> unfortunately I have quite some troubles when trying to use PWM on
> pin P0.8 (MAT2.1) of my LPC2101 controller (without the use of
> interrupts). The following code is what I have until now:
>
> // Configure P0.8
> PINSEL0 &= ~(3<<16);
> PINSEL0 |= 2<<16;
>
> T2TCR = 1<<1; // Reset TC and PC, disable timer
> T2PR = 5; // Prescaling
> T2MCR = 1<<10; // Reset on MR3 match
> PWM0CON = 1<<3; // Use single edged PWM for MR3
> T2EMR = 1<<1 | 3<<6; // Enable MAT2.1 and set toggle mode
>
> // Setup PWM parameters
> unsigned short cycles = 49152;
> T2MR3 = cycles; // Period duration
> T2MR1 = cycles/4; // Pulse width
> T2TCR = 1<<0; // Enable counter
>
> Prescaling and the value of the 'cycles' variable are computed
> depending on the frequency, the values above are just examples for
> F=200Hz (PCLK=58,982,400Hz). My problem is that the pulse remains
> constantly high for 5ms, then constantly low for 5ms. Seems like MR1
> is getting ignored. Any help available? Thanks in advance.
>
> -rfkd07
>

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

Re: Using PWM on an LPC2101 - rfkd07 - Jul 31 1:40:46 2008

Thanks Jeff, that solved my problem. Stupid me.
--- In l...@yahoogroups.com, "ksdoubleshooter" wrote:
>
> Remove the line setting up T2EMR and set up the RIGHT bit in the
> RIGHT PWMCON register.
>
> Jeff
>
------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )