Code to generate square wave form with varying frequency in run time. Duty cycle is constant - 50%. Frequency is varied in run time
for(;;)
{
PPG1_SetRatio16(PPGPtr,32767);
PPG1_SetPeriodMS(PPGPtr,1);
for(i=0;i<65535;i++)
{
__asm("nop");
}
PPG1_SetPeriodMS(PPGPtr,10);
for(i=0;i<65535;i++)
{
__asm("nop");
}
}
from interval - the table has three rows that contain the Initial value, low limit and high limit of the interval. Allows to change a timing freely within a selected interval (for low limit to high limit), while all values of the interval are selected with specified precision. Prescaler value is fixed in this mode, timing is set only using compare/reload registers value. It means that it is possible to reach all values within the interval by using the same prescaler.