Problem Solving Final
Problem Solving Final
Example: Configure the USB clock if an 8 MHz external driven primary clock.
Ans: UPLLIDIV has to be set to 2.
4MHz * 24 = 96 MHz
96 MHz / 2 = 48 MHz .
Remark 1: The clock configuration bits can be selected by programming SFR registers (e.g. OSCCON,
OSCTUN, and others) or the device configuration registers (e.g. DEVCFG1 and DEVCFG2).
Remark 2: The operating clock can be selected during the programming of the microcontroller chip
Example: TRISA=0x00FF configures the Port-A:
⮚ Pins associated with the lower 8 bits are input
Remark: You always need to configure the port before you use it. All I/O port pins are defined as inputs
after a Power-on Reset(POR).
TRISA = 0xFFF0;
TRISC = 0x00F0;
Functions:
Bit-wise operators in C:
EXAMPLE:
4) ~0x55 = 0xAA
EXAMPLE 1: Find the value for T1CON if Timer1 is programmed with no pre-scaler, internal clock source,
not gated.
EXAMPLE 2: Find the timer clock frequency of Timer1 if it is using internal clock (PBCLK = 8MHz) and it is
configured with
The analog input voltage of 3.65v will be represented by decimal number 748 or by
binary number 1011101100.
Using similar way we can find a binary representation for any desired level of the
analog input voltage.