Академический Документы
Профессиональный Документы
Культура Документы
PWM
• Pulse Width Modulation, or PWM, is a technique for getting analog results with
Vout
Vmin
Vout = Amp * Duty Cycle
Amp = Vmax – Vmin
31:8 7 6 5 4 3 2 1 0
000….0 0 1 0 0 0 0 0 1
Function PWM1.4 PWM1.1
LPC_PWM1->MR0 = 4000;
MATCH REGISTER 0 [TON + TOFF]
000….0 1 2 0 0
0001 0010 0000 0000
LPC_PWM1->TCR = 2;
LPC_PWM1->TCR = 9;
When TCR is 2:
Reset the counter
When TCR is 9:
Enable PWM
Enable Counter
31:4 3 2 1 0
PWM COUNTER COUNTER
Reserved Reserved
ENABLE RESET ENABLE
00…..000 0 0 1 0
00…..000 1 0 0 1
while(1)
{
for(dc=0; dc<4000; dc++)
{
LPC_PWM1->MR1 = dc;
LPC_PWM1->MR4 = 0;
PC_PWM1->LER = 0x31;
delay(5);
}
for(dc=0; dc<4000; dc++)
{
LPC_PWM1->MR4 =dc;
LPC_PWM1->MR1=0;
LPC_PWM1->LER=0x31;
delay(5);
}
}
}
LPC_PWM1->LER=0X31;
PCR REGISTER
31:7 6 5 4 3 2 1 0
Enable Enable Enable Enable Enable Enable Enable
Reserved PWM PWM PWM PWM PWM PWM PWM
Match 6 Match 5 Match 4 Match 3 Match 2 Match 1 Match 0
00….0 0 1 1 0 0 0 1
3 1
DC MOTOR
Use FRC 1 to interface