static void TAPwmSetDuty(char Channel,unsigned int Duty)
{
switch(Channel)
{
case 1: TBCCR1=Duty; break;
case 2: TBCCR2=Duty; break;
case 3: TBCCR3=Duty; break;
case 4: TBCCR4=Duty; break;
}
}
static void TAPwmSetPermill(char Channel,unsigned int Percent)
{
unsigned long int Period;
unsigned int Duty;
Period = TBCCR0;
Duty = Period * Percent / 1000;
TAPwmSetDuty(Channel,Duty);
}