PWM on the LPC1114

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

PWM on the LPC1114

2,418 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by akiwiguy on Sat Mar 06 23:36:13 MST 2010
Hi, I have a LPCXpresso board with a LPC1114 on it, and want to use it in a robotics project using a TI SN754410. But, I have no idea how. :confused:

First question: What pins have hardware PWM?
Second question: What code can I use to generate a PWM signal on two of those pins?

Thanks in advance
0 Kudos
Reply
6 Replies

2,102 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by akiwiguy on Tue Mar 09 17:19:25 MST 2010
Thanks NXP_Europe, I'm going to work on that code tonight and make it work for me.
0 Kudos
Reply

2,102 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Tue Mar 09 07:10:02 MST 2010
Hi all,
Please find attached the 16 bits and 32 bits timers including PWM initialization and usage.
Here a small example on how to call use these functions.

    
/* Initialize the PWM in timer32_1 enabling match0 output */
    init_timer32PWM(1, period, MATCH0|MATCH1);
    enable_timer32(1);
    setMatch_timer32PWM (1, 0, period/4);

    /* Initialize the PWM in timer16_1 enabling match0 output */
    init_timer16PWM(1, period, MATCH1, 0);
    enable_timer16(1);
    setMatch_timer16PWM (1, 1, period/8);
Kind regards,
0 Kudos
Reply

2,102 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brucesegal on Mon Mar 08 19:11:49 MST 2010
Here is some code for Timer32B1, more or less identical to the examples provided from NXP. Setting up any of the timers is about the same. Just read the user manual.

void initTimer32B0( void ) {

LPC_IOCON->JTAG_nTRST_PIO1_2 = (LPC_IOCON->JTAG_nTRST_PIO1_2 & ~0x7) | 0x3; //enable CT32B1_MAT1


LPC_SYSCON->SYSAHBCLKCTRL |= (1<<10); //enable clock to Timer32B1

LPC_TMR32B1->TCR = 2;     //reset counter
LPC_TMR32B1->TCR = 0;
LPC_TMR32B1->PR = 0;      //prescaler = 0
LPC_TMR32B1->MCR = (1<<10)|(1<<9); //reset TC on MC3 match
LPC_TMR32B1->MR3 = 856;   //set period - 48mhz / MR3+1 = 56khz
LPC_TMR32B1->MR1 = 428;   //set duty cycle
LPC_TMR32B1->PWMC = 1<<1 ;    //enable PWM on MAT1 output
LPC_TMR32B1->IR = 0xf;
LPC_TMR32B1->TCR = 1;     //counter enable

}
0 Kudos
Reply

2,102 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by akiwiguy on Sun Mar 07 14:58:15 MST 2010
That's very helpful mikejenx, thanks.


Quote:
you will need to setup the Timer into PWM mode and enable the two match pins.



How?
0 Kudos
Reply

2,102 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mikejenx on Sun Mar 07 14:24:13 MST 2010
I would use T16B0 as 16bit timer1 does not bring out MAT2 to a pin.
Use CT16B0_MAT1 and CT16B0_MAT2 as the two PWM outputs. This way you only need to use one timer.
Refer to Ch 12 of the User manual.
Set the prescale to 5Khz (for the SN754410)
Set CT16B0_Mat3 to 99, this will give you a range from 0-100%
Load CT16B0_MAT1 and MAT2 with the PWM value you need as a percentage
you will need to setup the Timer into PWM mode and enable the two match pins.
0 Kudos
Reply

2,102 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rmteo on Sun Mar 07 07:33:37 MST 2010
Look at [B]Section 7.12 - PWM Control Register[/B] and [B]Section 7.13 Rules for single edge controlled PWM[/B] outputs of the User Manual (UM 10398) on how to use PWM.  For the 16-bit Timer it is in Chapter 12 and for the 32-bit Timer in Chapter 13.
0 Kudos
Reply