lpcware

Lpc1347 pwm

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by ECamino on Tue Oct 16 06:52:33 MST 2012
Hi,

We have a board wired with PIO0_16 needing PWM as CT32B1_MAT3. We just need a 30% duty on 38kHz. I have the following code to set it up. Using MR2 for period and MR3 for the duty. But I see no output. Is there something else I need to do to get a signal?

[SIZE=2]GPIOSetDir(0,16,1); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// set port 1, pin 31 to output[/COLOR][/SIZE][/COLOR][/SIZE]

[LEFT][SIZE=2]LPC_IOCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO0_16[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (0x01<<2); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// set up for CT32B1_MAT3.[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]

[SIZE=2]LPC_SYSCON->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SYSAHBCLKCTRL[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (0x1<<10); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// enable peripheral clock to drive timer CT32B1[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2]LPC_CT32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MR2[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0x13b; [/SIZE]

[SIZE=2]LPC_CT32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MR3[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]= 0x69;[/SIZE]


[LEFT][SIZE=2]LPC_CT32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]EMR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (0x01<<10); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// may not be necessary for PWM?[/COLOR][/SIZE][/COLOR][/SIZE]
[LEFT][SIZE=2]LPC_CT32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MCR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (0x01<<7); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Set MR2R. TC reset on MRR match[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[/LEFT]



[SIZE=2]LPC_CT32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PWMC[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= (0x01<<3); [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// PWM enabled for channel 3.[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2]LPC_CT32B1->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]TCR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 1; [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// turn on the timer[/COLOR][/SIZE][/COLOR][/SIZE]

Outcomes