Assignment 2
OBJECTIVE: Flashing LEDs connected to port pin
(PIC16F877):
The objective of this practical assignment is to familiarize the
learner with some of the PIC microcontroller commands and to learn
how fixed time delay routines are generated. Fixed time delay
routines are used quite often in a variety of I/O interfacing tasks
such as switch contact debouncing, periodic pulse width generation,
slowing down of micro-controller for human interfacing etc…
PROGRAM DESCRIPTION:
1. Making use of MPLAB IDE, write firmware code to switch all LED’s
connected to port pins RD0-RD7
continuously on for one second and then off for one second.
2. First use a flowchart to determine the program structure and
then generate your commented firmware
source code.
PROCEDURE:
1. Making use of the text editor in MPLAB IDE, enter the given
program extract and save the source file with
an “.asm” extension.
2. Create a Project within MPLAB and attach the source code
file.
3. Compile the source code by building the project. This will then
produce a hex-file version of the original
source code.
4. Identify and rectify any code errors and then recompile the
source code.
5. Interrogate the generated list file and hex file to familiarize
yourself with the structure of these files.
6. Simulate the program by stepping though the program in
“single-step” mode and hence verifying that the
program is working correctly.
Program:
Hi-Tech C Code #include <htc.h> #define _XTAL_FREQ 8000000 void main() { TRISB=0X00; PORTB=0X00; while(1) { PORTB=0XFF; __delay_ms(1000); PORTB=0X00; __delay_ms(1000); } }
This is the core style of writing the microcontroller program. As you can see, the style is completely similar to that of the normal C programs. Just some additional keywords here. Remember that all the syntax and mathematical and logical operations supported by stdio and conio libraries are accepted here in htc library with some additional ones also.
Assignment 2 OBJECTIVE: Flashing LEDs connected to port pin (PIC16F877): The objective of this practical assignment...