Microcontroller Programming Laboratory Notes, Lab Reports of Electronics

These are laboratory notes containing the code for an 8-bit microcontroller using the harvard architecture. The code includes function definitions for delays and the main program logic, which uses a switch statement to control the output pins based on the input. Written in the c programming language using the reg52 library.

Typology: Lab Reports

2020/2021

Uploaded on 11/19/2021

eujean-clare-gonzaga
eujean-clare-gonzaga 🇵🇭

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Christian Noel Eslit
BCA151 B185
Laboratory3
#include<reg52.h>
sbit OUT0 = P1^3;
sbit OUT1 = P1^4;
sbit OUT2 = P1^5;
sbit OUT3 = P1^6;
sbit OUT4 = P1^7;
void delay1()
{
unsigned char m;
TR0 = 0;
for(m=0; m<30; m++)
{
TH0 = 60;
TL0 = 176;
TF0 = 0;
TR0 = 1;
while(TF0==0);
TR0 = 0;
}
}
void delay2()
{
unsigned char m;
TR0 = 0;
for(m=0; m<50; m++)
pf3
pf4

Partial preview of the text

Download Microcontroller Programming Laboratory Notes and more Lab Reports Electronics in PDF only on Docsity!

Christian Noel Eslit BCA151 B Laboratory 3 #include<reg52.h> sbit OUT0 = P1^3; sbit OUT1 = P1^4; sbit OUT2 = P1^5; sbit OUT3 = P1^6; sbit OUT4 = P1^7; void delay1() { unsigned char m; TR0 = 0; for(m=0; m<30; m++) { TH0 = 60; TL0 = 176; TF0 = 0; TR0 = 1; while(TF0==0); TR0 = 0; } } void delay2() { unsigned char m; TR0 = 0; for(m=0; m<50; m++)

TH0 = 60;

TL0 = 176;

TF0 = 0;

TR0 = 1;

while(TF0==0); TR0 = 0; } } void main() { unsigned char x; TMOD = TMOD & 0xF0; TMOD = TMOD | 0x01; P1 = 0x03; while(1) { x = P1 & 0x03; switch(x) { case 0x00: OUT0 = 1; OUT1 = 1; OUT2 = 1;

OUT1 = 1;

OUT2 = 1;

OUT3 = 0;

OUT4 = 0;

delay2(); OUT0 = 0; OUT1 = 0; OUT2 = 0; OUT3 = 1; OUT4 = 1; delay2(); break; case 0x03: OUT0 = 0; OUT1 = 0; OUT2 = 0; OUT3 = 0; OUT4 = 0; } } }