Sie sind auf Seite 1von 2

EET203 Microcontroller System Design Tutorial 2 - Timer

Timers 1. Find the timers clock frequency and its period for PIC16F877A, with the following clock frequency. Assumed no pre-scaler is used. a. 20 MHz b. 10 MHz c. 4 MHz 2. Repeat Question 1 with pre-scaler 16 and 256. 3. From Question 2, obtain the bit setting configuration for: a. Timer0 control register for internal clock, low to high transition. b. Timer0 control register for external clock, low to high transition. c. Timer1 control register for internal clock, low to high transition. d. Timer1 control register for external clock, low to high transition. 4. By setting related PIC16F877A SFRs and at XTAL = 10 MHz, obtain: a. A square wave of 50% duty cycle on pin PORTB0 for Timer1 without pre-scaler. b. A square wave with a period of 15ms on pin PORTB0 for Timer1 without prescaler. 5. Write a program using Timer1 to generate a 1 kHz and a 2 kHz square wave frequency on PORTB0 and PORTB4 respectively. PORTC6 and PORTC7 will be used as switches to select the frequencies. If PORTC6 is pressed, a 1 kHz square wave will be generated and if PORTC7 is pressed, a 2 kHz square wave will be generated.

CCP 1. Obtain the bit setting configuration for CCP1CON register in: a) Compare mode, toggle pin CCP1 upon match without pre-scaler. b) Capture mode, rising edge of every pulse. 2. Find the PR2 value and the pre-scaler needed to get the following PWM frequencies with XTAL = 20 MHz. a) 1.22 kHz b) 4.88 kHz c) 78.125 kHz 3. The project in Figure 1 is based on a PIC16F877A, with the purpose to control a DC FAN using PWM (Pulse with Modulation) mode at 300 sec period. It offers 3 speed setting from switch SW1, SW2 and SW3. The PIC16F877A receive the signal from these switches and perform action according to the following parameters: If SW1 is pressed, PWM duty cycle is at 20% If SW1 and SW2 are pressed, PWM duty cycle is at 40% If SW1, SW2 and SW3 are pressed, PWM duty cycle is at 60%. From the schematic shown, write a complete program (in C) for the project if XTAL = 20 MHz.

Figure 1

Das könnte Ihnen auch gefallen