TANDEM
21-04-2011, 12:46 AM
16.5.8 SETUP FOR PWM OPERATION
The following steps should be taken when configuring
the ECCP1 module for PWM operation:
1. Configure the PWM module:
a) Disable the ECCP1/P1A, P1B, P1C and/or
P1D outputs by setting the respective TRISD
bits.
b) Set the PWM period by loading the PR2
register.
c) Set the PWM duty cycle by loading the
ECCPR1L register and ECCP1CON<5:4>
bits.
d) Configure the ECCP1 module for the
desired PWM operation by loading the
ECCP1CON register with the appropriate
value. With the ECCP1M<3:0> bits, select
the active-high/low levels for each PWM
output. With the EPWM1M<1:0> bits, select
one of the available output modes.
e) For Half-Bridge Output mode, set the dead-
band delay by loading the ECCP1DEL
register with the appropriate value.
2. Configure and start TMR2:
a) Clear the TMR2 interrupt flag bit by clearing
the TMR2IF bit in the PIR1 register.
b) Set the TMR2 prescale value by loading the
T2CKPS bits (T2CON<1:0>).
c) Enable Timer2 by setting the TMR2ON bit
(T2CON<2>) register.
3. Enable PWM outputs after a new cycle has
started:
a) Wait until TMR2 overflows (TMR2IF bit
becomes a ‘1’). The new PWM cycle begins
here.
b) Enable the ECCP1/P1A, P1B, P1C and/or
P1D pin outputs by clearing the respective
TRISD bits.
Tôi đã cố gắng đọc nhưng quả thật không thể hiểu để vận dụng chuyển thành CCS. Vậy nhờ các tiền bối giúp tôi cấu hình cho EPWM của Pic18F458 bằng CCS để sử dụng 5 kênh điều xung (C2, D4, D5, D6, D7). Xin chân thành cám ơn!
The following steps should be taken when configuring
the ECCP1 module for PWM operation:
1. Configure the PWM module:
a) Disable the ECCP1/P1A, P1B, P1C and/or
P1D outputs by setting the respective TRISD
bits.
b) Set the PWM period by loading the PR2
register.
c) Set the PWM duty cycle by loading the
ECCPR1L register and ECCP1CON<5:4>
bits.
d) Configure the ECCP1 module for the
desired PWM operation by loading the
ECCP1CON register with the appropriate
value. With the ECCP1M<3:0> bits, select
the active-high/low levels for each PWM
output. With the EPWM1M<1:0> bits, select
one of the available output modes.
e) For Half-Bridge Output mode, set the dead-
band delay by loading the ECCP1DEL
register with the appropriate value.
2. Configure and start TMR2:
a) Clear the TMR2 interrupt flag bit by clearing
the TMR2IF bit in the PIR1 register.
b) Set the TMR2 prescale value by loading the
T2CKPS bits (T2CON<1:0>).
c) Enable Timer2 by setting the TMR2ON bit
(T2CON<2>) register.
3. Enable PWM outputs after a new cycle has
started:
a) Wait until TMR2 overflows (TMR2IF bit
becomes a ‘1’). The new PWM cycle begins
here.
b) Enable the ECCP1/P1A, P1B, P1C and/or
P1D pin outputs by clearing the respective
TRISD bits.
Tôi đã cố gắng đọc nhưng quả thật không thể hiểu để vận dụng chuyển thành CCS. Vậy nhờ các tiền bối giúp tôi cấu hình cho EPWM của Pic18F458 bằng CCS để sử dụng 5 kênh điều xung (C2, D4, D5, D6, D7). Xin chân thành cám ơn!