PWM to control Servos with LPC1769

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PWM to control Servos with LPC1769

1,400 Views
thoret
Contributor II

I need 3 PWM signals to control 3 servos.

I need a rate with 50Hz = 20ms.

The duty cycle should be from about 0,9 ms to 2 ms.

    LPC_SC->PCONP |= 1 << 6; // Set PWM1 power7clock control bit

    LPC_SC->PCLKSEL0 |= 1 << 12; // Peripheral clock selection for Timer2 ; PWM clock = microcontroller clock i.e the         prescaler value is 1.

    LPC_PINCON->PINSEL4 = (0x1<<0) | (0x1<<2) | (0x1<<4); // Set Output P2.0 P2.1 P2.2 as PWM1.1 PWM1.2 PWM1.3

    LPC_PINCON->PINMODE4 |= 1 << 9; // enable neither pull up nor pull down.

    LPC_PWM1->MR0 = 20000; // PWM freq = 50 Hz = 20 ms

    LPC_PWM1->MCR |= 1 << 1; // Reset timer on Match0

    LPC_PWM1->MR5 = 1000;  // PWM Duty Cycle = 1000 Hz = 1 ms

    LPC_PWM2->MR3 = 1500;    // PWM Duty Cycle = 1000 Hz = 1 ms    LPC_PWM3->MR4 = 2000;     // PWM Duty Cycle = 1000 Hz = 1 ms

    LPC_PWM1->TCR |= (1 << 0) | (1 << 3);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I use the LPC1769

The settings are right? Will I get 3 different PWM signals at the output pins?

SERVO Motor with PWM Signal

Labels (2)
0 Kudos
Reply
2 Replies

872 Views
Jonathan_Iglesias
NXP TechSupport
NXP TechSupport

Dear Thore T,

Hope you are doing great,

Can you please tell me which LPC are you using ?

Have a great day.

Jonathan

0 Kudos
Reply

872 Views
thoret
Contributor II

Hi Jonathan Iglesias

I use the LPC1769.

Regards

Thore

0 Kudos
Reply