0% found this document useful (0 votes)
2 views

Problem Solving Final

Uploaded by

asookaf21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Problem Solving Final

Uploaded by

asookaf21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CSE 371: Problem Solving:

These are the problem-solving examples from the slides

Example: Configure the USB clock if an 8 MHz external driven primary clock.
Ans: UPLLIDIV has to be set to 2.

Verify: 8 MHz / UPLLIDIV = 4 MHz

4MHz * 24 = 96 MHz

96 MHz / 2 = 48 MHz .

Remark: PLLx24 input must be between 4 and 5 MHz

UPLLEN and UFRCEN select the clock at the output

Example: Suppose we use 8 MHz crystal, we want a 80 MHz clock output.


Answer: Assign the following values FPLLIDIV = 2,

FPLLMUL = 20, FPLLODIV = 1

Input frequency = 8 MHz

8 MHz / FPLLIDIV = 4 MHz

4 MHz * FPLLMUL = 80 MHz

80 MHz / FPLLODIV = 80 MHz (output freq.)

Remark: PLLMULT input (FIN) must be between 4 and 5 MHz

COSC selects the CPU clock at the output.

Example: If CPU system clock is 80 MHZ then


The peripheral clock can be 80, 40, 20, or 10 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

⮚ Pins associated with the upper 8 bits are output.

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).

TRISx bit = 0 sets up digital output

TRISx bit = 1 sets up digital input

TRISA = 0xFFF0;

TRISA = 0b1111 1111 1111 0000;

⮚ Makes bits 0, 1, 2, 3 digital outputs

TRISC = 0x00F0;

TRISC = 0b0000 0000 1111 0000;

⮚ Makes bits 4, 5, 6, 7 digital inputs

TRISEbits.TRISE0 = 0 ; // E0 as output pin

⮚ Makes bit 0 of port E a digital output bit

Functions:

PORTSetPinsDigitalOut(IOPORT_C, IOPORT_PIN_6 |IOPORT_PIN_7);

Bit-wise operators in C:
EXAMPLE:

1) 0x35 & 0x0F= 0x05

2) 0x04 | 0x68 =0x6C

3) 0x54 ^ 078 = 0x2C

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

(a) No pre-scaler 1:1 (TCKPS = 0)

(b) Pre-scaler 1:8 (TCKPS = 3)


Triangle method
We can use the triangle method to calculate/find the binary representation of an
analog input voltage. For example, lets calculate/find the binary value
representation on the analog input voltage of 3.65 volt;

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.

For correct analog-to-digital conversions, the ADC conversion


clock (TAD) must be selected to ensure a minimum TAD time of
83.33 ns

You might also like