Monday, December 3, 2007

Balinese Learn To Delay PIC 16F84

PIC 16F84 DELAYING
Project Description

This project should be done after finishing the previous project (PIC 16F84 TESTING). In this assignment we will try to make a delay for PIC 16F84 microcontroller. Assemble the circuit for testing and check the output port (RA0) using logic probe. The port A0 (RA0) will blink.

Tools and Parts Needed


* PIC 16F84
* 4 Mhz Crystal Oscillator
* 33 pF Capacitor (2 units)
* Logic Probe
* Breadboard
* 5 Volt Power Supply

* MPLAB Software

Basic Theory


Term Delaying means make microcontroller waiting for This could be done by looping the program flow for several times. Looping for several times make a delay time for microcontroller. If the circuit using a 4 MHz crystal, then each instruction will take 1/4 MHz (it's means 1 micro second to complete). So, check the delay time you need and make an adequate loops.

PIC 16F84 has some 8-bit general puposes registers at bank 0 and bank 1. We can use the register as a looping counter. Due to 8-bit width, the maximum number is 0xff or 255. Therefore, to reach 1000000 loops we need 255 x 255 x 15 loops.

Use MPLAB IDE to write, simulate and program the PIC 16F84. Please click on Microchip link to get a free MPAB software.

Experiment Steps

Step 1:

Assemble the Circuit on the Breadboard as picture follows.



Step 2:


Program the PIC 16F84 as follows using MPLAB. Make sure that column 1 is used for label only.

INCLUDE "P16F84.INC"

RAM1 EQU 0X0C
RAM2 EQU 0X0D
RAM3 EQU 0X0E

BSF STATUS, RP0
MOVLW 0X00
MOVWF TRISA

ULANG
BCF STATUS, RP0
BSF PORTA,0
CALL DELAY
BCF PORTA,0
CALL DELAY
GOTO ULANG

DELAY
MOVLW 0XFF
MOVWF RAM1
LOOP1
MOVLW 0XFF
MOVWF RAM2
LOOP2
MOVLW 0XFF
MOVWF RAM3
LOOP3
DECFSZ RAM3,F
GOTO LOOP3
DECFSZ RAM2,F
GOTO LOOP2
DECFSZ RAM1,F
GOTO LOOP1
RETURN

END

3. Download it to the PIC.

4. Connect the circuit to power supply.

5. Check on port RA0 using logic probe.

No comments: