Hi Does anyone know where to find any example of implementing PWM using CAPCOM especially in XC161 (16 bit microcontroller)? MJ
No problem, the timer T0 is running at a clock frequency of 20MHz/64 = 3.2usec per tick. The CAPCOM timers can ONLY count up. The example uses the CAPCOM channel 0 in Compare Mode 3 and is associated to T0. I arbitrarily selected a period of 100mseconds. So 100msec/3.2usec = 31250 or 0x7A12 counts. Since the CAPCOM can only count up you need to subtract this from 0x10000 which gives you 0x10000 – 0x7A12 = 0x85EE. Does this answer your question? -Chris