0% found this document useful (0 votes)
80 views3 pages

ECAPP Lab6 PDF

Uploaded by

Isaiah Rafael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views3 pages

ECAPP Lab6 PDF

Uploaded by

Isaiah Rafael
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Diploma in ELN

Diploma in CEN

Embedded Control and Applications


(EMC3002)

Name: Class:
Facilitator’s Comments: Matric No:

Laboratory 6: Power Management


Objectives:
i) Learn about the power management modes of the PIC18F4520.
ii) Learn to set up and configure the PIC18F4520 to operate in various power
management modes.
iii) Implement program to enter into and leave from the sleep mode.
iv) Use MPLAB X IDE and ICD3.

Equipment:
i) Computer with USB ports
ii) ECAPP Target Board
iii) MPLAB ICD3
iv) Current measurement circuit board
v) Digital Multi-meter

Software:
i) MPLAB® X IDE v3.55
ii) XC8 ver1.41

References:
i) MPLAB® X IDE User’s Guide

ECAPP Oct 2020 Property of TP, Copyright © Page 1


Basic Power Management Application

The program below will blink the LEDs for five times and enter into sleep mode.
Upon an INT0 interrupt, the micro-controller resumes execution.

• Create a project. Name the project as Lab6.


• Create a new source file in the project folder. Name the file as lab6_1.c.
• Enter the following code to the source file. Fill up the missing blanks with
appropriate C statements.
// PIC18F4520 Configuration Bit Settings

#pragma config OSC = XT // Oscillator Selection bits (XT oscillator)


#pragma config LVP = OFF // Single-Supply ICSP Enable bit
#pragma config WDT = OFF // Watchdog Timer Enable bit

#include <xc.h>
#include <stdlib.h>

#define _XTAL_FREQ 4000000


#define SPEAKER PORTBbits.RB3

void interrupt ISR (void);

void main(void)
{
char i;
OSCCON = 0;
____________________ // Configure all ports as digital
____________________ // Configure RA<3:0> as outputs (LEDs)
____________________ // Configure RB3 as output (speaker)

// Set up for INT0 interrupt


____________________ // Disable global interrupt
____________________ // Clear INT0 interrupt flag
____________________ // Configure INT0 interrupt on rising edge
____________________ // Enable INT0 interrupt
____________________ // Enable global interrupt

while (1)
{
for (i=0; i<5; i++)
{
____________________ // Turn on all LEDs
__delay_ms(300);
____________________ // Turn off all LEDs
__delay_ms(300);
}
SLEEP(); // library function to execute sleep instruction
}
}

ECAPP Oct 2020 Property of TP, Copyright © Page 2


void interrupt ISR(void)
{
int x;

if (____________________) // Check INT0 flag to confirm if INT0 interrupt trigger


{
for (x=0; x<3000; x++) // Sound the speaker
{
SPEAKER = 1;
_delay(500);
SPEAKER = 0;
_delay(500);
}

____________________ // Clear interrupt flag


}
}

• Analyse the above program and predict what would happen when the program is
executed.

• Analyse the above program and predict what would happen when the INT0
interrupt occurs?

• Build the project, download the program into the PIC18F4520 flash memory and
run the application. Describe what you have observed.

• Use the current measurement board provided and the digital multi-meter to
measure the current at run mode and sleep mode, respectively. Calculate the
current saving at sleep mode.

~ END OF LABORATORY 6 ~

ECAPP Oct 2020 Property of TP, Copyright © Page 3

You might also like