1、默认的TIMER对应的PWM输出的IO口
PWM0–TIMER0–PA1
PWM1–TIMER1–PA4
PWM2–TIMER2–PB3
PWM3–TIMER3–PB4
PWM不通过OUTPUTCHANNEL设置的时候,PWM从默认的IO口输出
2、由于TIMER0作系统时钟,所以最多可以输出3路PWM,而且3路PWM可以通过OUTPUTCHANNEL
输出到任意的IO口上,输出3路PWM参考程序,
void led_pwm_init(void)
{
set_timer1_pwm(500L, 10);
set_timer3_pwm(500L, 50);
set_timer2_pwm(500L, 90);
}
static void set_timer1_pwm(u32 fre, u8 duty)
{
SFR(JL_IOMAP->CON3, 20, 4, 3);//CHANNEL1,对应输出IO口的OUT:0,DIE:1
JL_TIMER1->CON = 0x0000;
JL_TIMER1->PRD = OSC_Hz / (4 * fre);
JL_TIMER1->PWM = (JL_TIMER1->PRD * duty) / 100;
JL_TIMER1->CON = (1 << 4) | (1 << 8) | (1 << 0) | (2 << 2);
JL_PORTA->PU |= BIT(12);
JL_PORTA->PD |= BIT(12);
JL_PORTA->DIR &= ~BIT(12);
JL_PORTA->OUT &= ~BIT(13);
JL_POR