Lab Report
Number of Experiment: 01
Name of the Experiment: Introduction to microcontroller based circuit programming and
simulation
Course Name: Fundamentals of Embedded system.
Course Code: EEE 306
Date of Submission: 21-02-2024
Submitted To:
Dr. Muhammed Mazharul Islam
Assistant Professor
Dept. of EEE, East West University
Submitted by:
Md Abir Hossain
ID: 2021-2-80-026
Objective:
The goal of this lab is to learn to program and simulate microcontroller system based specific
tasks.
Circuit:
Code:
/*
* File: Lab 1 a.c
* Author: USER
*
* Created on February 21, 2024, 11:23 AM
*/
// PIC16F690 Configuration Bit Settings
// 'C' source line config statements
// CONFIG
#pragma config FOSC = INTRCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on
RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by
SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input,
MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown-out Reset Selection bits (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is
disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is
disabled)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
#define _XTAL_FREQ 8000000
void main(void) {
TRISA0=1;
TRISA1=1;
TRISC=0;
ANSEL=0x00;
ANSELH=0x00;
nRABPU=0;
WPUA=1;
while(1){
if(RA0==0){//switch on
RC0=1;
__delay_ms(500);//delay of 500ms
RC0=0;
__delay_ms(500);//delay of 500ms
RC1=1;
__delay_ms(500);//delay of 500ms
RC1=0;
__delay_ms(500);//delay of 500ms
RC2=1;
__delay_ms(500);//delay of 500ms
RC2=0;
__delay_ms(500);//delay of 500ms
RC3=1;
__delay_ms(500);//delay of 500ms
RC3=0;
__delay_ms(500);//delay of 500ms
}
else if (RA1==0){
RC0=0;
RC1=0;
RC2=0;
RC3=0;
}
}
return;
Circuit:
Code:
// CONFIG
#pragma config FOSC = INTRCIO // Oscillator Selection bits (INTOSCIO oscillator: I/O function on
RA4/OSC2/CLKOUT pin, I/O function on RA5/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by
SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input,
MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown-out Reset Selection bits (BOR disabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal External Switchover mode is
disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is
disabled)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
#define _XTAL_FREQ 8000000
void main(void) {
TRISC=0;
ANSEL=0;
ANSELH=0;
OPTION_REG=0;
while(1)
{
RC0=1;
RC1=1;
__delay_ms(100);
RC0=0;
RC1=0;
__delay_ms(100);
RC2=1;
RC3=1;
__delay_ms(100);
RC2=0;
RC3=0;
__delay_ms(100);
RC4=1;
RC5=1;
__delay_ms(100);
RC4=0;
RC5=0;
__delay_ms(100);
RC6=1;
RC7=1;
__delay_ms(100);
RC6=0;
RC7=0;
__delay_ms(100);
}
return;
}