139k views
2 votes
It is required to generate a 12kHz square wave from the PIC using Timer 0 . The OSCCON register is loaded by 0b01010000. Find the following:

a: The clock time Tclk based on the osccon value, Fose =2Mhz⇒Tclk=0.5us

User BlackSheep
by
7.9k points

1 Answer

1 vote

Final answer:

To generate a 12kHz square wave from the PIC using Timer 0, you need to calculate the Prescaler value based on the given formula and the provided values. The Prescaler value can then be set in the T0PS bits of the OPTION_REG register.

Step-by-step explanation:

To generate a 12kHz square wave from the PIC using Timer 0, we can use the following formula:

Tclk = 1 / (2 * Freq * Prescaler * TMR0)

Given Fose = 2MHz and Tclk = 0.5us, we can rearrange the formula to solve for the Prescaler:

Prescaler = Fose / (2 * Freq * Tclk * TMR0)

Substituting the values, we get: Prescaler = 2e6 / (2 * 12e3 * 0.5e-6 * TMR0)

In order to calculate the Prescaler value, we need to know the value of TMR0. Once we have the Prescaler value, we can set it in the T0PS bits of the OPTION_REG register.

User Vladimir Ignatov
by
7.8k points