


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 4
This page cannot be seen from the preview
Don't miss anything!



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++)
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;
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; } } }