配套测试代码:
void DRV_TMR16_PWM_Enable( uint16_t unit )
{
TMR16B0.PR.reg = unit;
TMR16B0.TCR.field.CEN = 1;
}
void DRV_TMR16_PWM1 ( uint16_t mr0, uint16_t mr0_2 )
{
//Using match control 0
TMR16B0.MR0.reg = mr0;
TMR16B0.MR0_2.reg = mr0_2;
TMR16B0.EMR.field.EMC0 = 0x3;
TMR16B0.EMR.field.EMC0_2 = 0x3;
TMR16B0.MCR.field.MR0R_2 = 1;
}
void DRV_TMR16_PWM2 ( uint16_t mr1, uint16_t mr1_2 )
{
//Using match control 1
TMR16B0.MR1.reg = mr1;
TMR16B0.MR1_2.reg = mr1_2;
TMR16B0.EMR.field.EMC1 = 0x3;
TMR16B0.EMR.field.EMC1_2 = 0x3;
TMR16B0.MCR.field.MR1R_2 = 1;
}
void DRV_TMR16_PWM3 ( uint16_t mr2, uint16_t mr2_2 )
{
//Using match control 2
TMR16B0.MR2.reg = mr2;
TMR16B0.MR2_2.reg = mr2_2;
TMR16B0.EMR.field.EMC2 = 0x3;
TMR16B0.EMR.field.EMC2_2 = 0x3;
TMR16B0.MCR.field.MR2R_2 = 1;
}
void DRV_TMR16_PWM4 ( uint16_t mr3, uint16_t mr3_2 )
{
//Using match control 3
TMR16B0.MR3.reg = mr3;
TMR16B0.MR3_2.reg = mr3_2;
TMR16B0.EMR.field.EMC3 = 0x3;
TMR16B0.EMR.field.EMC3_2 = 0x3;
TMR16B0.MCR.field.MR3R_2 = 1;
}
void DRV_TMR16_PWM_ALL ( uint16_t mr, uint16_t mr_2 )
{
//Using match control 0
TMR16B0.MR0.reg = mr;
TMR16B0.MR0_2.reg = mr_2;
TMR16B0.EMR.field.EMC0 = 0x3;
TMR16B0.EMR.field.EMC0_2 = 0x3;
//Using match control 1
TMR16B0.MR1.reg = mr;
TMR16B0.MR1_2.reg = mr_2;
TMR16B0.EMR.field.EMC1 = 0x3;
TMR16B0.EMR.field.EMC1_2 = 0x3;
//Using match control 2
TMR16B0.MR2.reg = mr;
TMR16B0.MR2_2.reg = mr_2;
TMR16B0.EMR.field.EMC2 = 0x3;
TMR16B0.EMR.field.EMC2_2 = 0x3;
//Using match control 3
TMR16B0.MR3.reg = mr;
TMR16B0.MR3_2.reg = mr_2;
TMR16B0.EMR.field.EMC3 = 0x3;
TMR16B0.EMR.field.EMC3_2 = 0x3;
TMR16B0.MCR.field.MR3R_2 = 1;
}