You are on page 1of 19

KEIL PROGRAMMING

PROGRAM:
Flash the output without delay # include <REG52.h> # include <intrins.h> void main (void) { int i = 0; while (1) { while (i<=25) { _nop_ ( ); i++; } if ( p1 = 0x00) { p1 = 0xff; } else { p1 = 0x00; } } }

Expt. No. : 02 Date FLASH THE OUTPUT WITH DELAY AIM: To perform Flash The Output With Delay operation using 8051 simulation environment KEIL C. COMPONENTS REQUIRED: KEIL C simulation software.. ALGORITHM: Step 1: Put the value to port 1 as 0xFF. Step 2: Run a delay loop. Step 3: Put the value to port 1 as 0xDD. :

PROGRAM:
Flash the output with delay # include <REG52.h> void sfr p2 = 0x00; void main ( ) { unsigned char x; p2 = 0xff; for (x = 0; x <= 150; x++) delay ( ); while (1) { p2 =~ p2; for (x = 0; x <= 20; x++) delay ( ); } } Delay subroutine Void delay (void) { TMOD = 0x100; TL1 = 0xFE; TH1 = 0xA5; While (TF1 == 0); TR1 = 0; TH1 = 0; }

OUTPUT:

RESULT: Thus the Flash Output With Delay operation using 8051 simulation environment KEIL C was performed and verified successfully.

PROGRAM: Rotate Right


#include<reg52.h> #include<intrins.h> #include<stdio.h> void main(void) { int i=0; int a,b; P1= 0xFF; while(1) { while(i<5) { _nop_(); i++; } a^=0xA5; P0=a; b^=_cror_(a,1); P1=b; } }

Expt. No. : 03(a) Date ROTATE RIGHT WITH DELAY AIM: To perform Rotate Right With Delay operation using 8051 simulation environment KEIL C. COMPONENTS REQUIRED: KEIL C simulation software.. ALGORITHM: Step 1: Start the program. Step 2: Put the value of Port 0 as 100101(A5). Step 3: Shift the bit towards right continously. Step 4: Call Delay routine. Step 5: get the value of port 1 as 11010010(D2). Step 6: End the program. :

OUTPUT:

RESULT: Thus the Rotate Right With Delay operation using 8051 simulation environment KEIL C was performed and verified successfully.

PROGRAM: Rotate Left


#include<reg52.h> #include<intrins.h> #include<stdio.h> void main(void) { int i=0; int a,b; P1= 0xff; while(1) { while(i<5) { _nop(); i++; } a^=0xA5; P0=a; b^=_cror_(a,3); P1=b; } }

Expt. No. : 03(b) Date ROTATE LEFT WITH DELAY AIM: To perform Rotate Left With Delay operation using 8051 simulation environment KEIL C. COMPONENTS REQUIRED: KEIL C simulation software.. ALGORITHM: Step 1: Start the program. Step 2: Put the value of Port 0 as 1001010(A5). Step 3: Shift the bit towards right continously. Step 4: Call Delay routine. Step 5: get the value of port 1 as 11010010(D2). Step 6: End the program. :

OUTPUT:

RESULT: Thus the Rotate Left With Delay operation using 8051 simulation environment KEIL C was performed and verified successfully.

PROGRAM:
Code locking # include <REG52.h> # include <stdio.h> char_get key (void); void main (void) { char i; int j = 0; SCON = 0x50; TMOD = 0x20; TH1 = 221; TD1 = 1; TI = 1; While (1) { if (j>3) { i = _get key ( ); if (j = = a) { printf ( code correct \n); } else { i++; printf ( code not correct\n); if (i = = 3) printf ( code locked); } } } }

Expt. No. : 04 Date CODE LOCKING AIM: To perform Code Locking operation using 8051 simulation environment KEIL C. COMPONENTS REQUIRED: KEIL C simulation software.. ALGORITHM: Step 1: Start the program. Step 2: Write program in IDE. Step 3: Compile the program. Step 4: Run the Simulator. Step 5: End the program. :

OUTPUT:

RESULT: Thus the Code Locking operation using 8051 simulation environment KEIL C was performed and verified successfully.

You might also like