Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Experiment No.

Aim: Generate a square wave.

 Program Statement:
Assuming XTAL = 10MHz , write a program to generate a square wave 0f 2KHz
frequency on pin PORTB.3.Use Timer0 with 16 bit mode.

 Software :
MPLAB IDEv8.88

 Procedure:
1. Choose Configure>select Device. In the device dialog ,select PIC18F8720 from the list.
2. Choose Project>Project Wizard.
From the Welcome dialog, click on Next>to advance.
3. Step 2 of the Project Wizard sets up the language tools that are used with this project.
Select “Microchip MPASM Tool suite” in the Active Tool suite list box.
4. Step Three of the wizard allows you to name new project and put it into a folder.
5. Select the template file and add it to project
C:\Progarm Files\Microchip\MPASMsuite\Template\Object\18F8720TMPO.asm. Press
Add>to move the file name to the right panel. Click on the “A” at the start of the line
with the file name three times until a “C” appears . this will enable this file to be copied
to our project directory.
6. Open the template file in the project by double clicking on its name in the Project
window.
7. Type the program and variables need to be defined is added in the UDATA_ACS section
for uninitialized data using Access RAM
8. Select Project>Build All to assemble and link the code.
9. Select MPLAB SIM simulator as the debug execution tool. This is done from the
Debugger>Select Tool pull down menu.
10. Select File>Save Workspace to save the Project.
11. Select Debugger>Reset>Processor Reset and a green arrow shows where the program
will begin. This was part of the template file. The first instruction in memory jumps to the
label called Main, where your code was inserted.
12. Press the Step into icon or select Debugger>step Into to single step to the code at Main
or Start.
13. Select View>Watch and add SFRs and SYMBOLs to be watched.
14. Select View> File Registers to watch the locations in the data file.

 Conclusion:

Department of Electrical Engineering, Viva tech Prof. Ashwini Haryan


[Type here]
Experiment No.6

 Program:

;Program for generating 2KHz square wave

#include<p18F8720.inc>

ORG 0X00
GOTO START

START BCF TRISB,3


MOVLW 0X08
MOVWF T0CON
HERE MOVLW 0XFD
MOVWF TMR0H
MOVLW 0X8E
MOVWF TMR0L
BCF INTCON,TMR0IF
CALL DELAY
BTG PORTB,3
BRA HERE

DELAY BSF T0CON,TMR0ON


AGAIN BTFSS INTCON,TMR0IF
BRA AGAIN
BCF INTCON,TMR0IF
BCF T0CON,TMR0ON
RETURN
END

Department of Electrical Engineering, Viva tech Prof. Ashwini Haryan


[Type here]
Experiment No.6

 Result:

Department of Electrical Engineering, Viva tech Prof. Ashwini Haryan


[Type here]

You might also like