INTEL 8051 (AT 89C51/C52/S51/S52) Assembly Programming

8051 Microcontroller - All Details Regarding Programming in Assembly & C Programming i will update here.










Download Instruction Set For Programming

8051 Android Phone AssemblyProgram Simulator - This is basic simulator for 8051 architecture IC for mobile phone. Its very useful.

You can compile program and check whether program is working with available hardwares in mobile.
Download 8051 simulator(Android )










Simulator Video

8051 LED Blink Program

We can blink led or start a hello world program by assembly in two ways
1. By Implimenting timers 
2. By using registers as counters
Timer is more accurate than register sothat timers are used in serial communications.

LED Blink Using Registers

LED BIT P1.0 ;-------------------------------------------- ORG 00H ;-------------------------------------------- MAIN: CLR LED ACALL DELAY3 SETB LED ACALL DELAY3 SJMP MAIN ;------------------------------------------- DELAY3: MOV R7,#45 D3L1: MOV R6,#255 D3L2: MOV R5,#255 DJNZ R5,$ DJNZ R6,D3L2 DJNZ R7,D3L1 RET ;----------------------------------------------- END ;--------------

LED Blink Using Timer

MOV P1,#00H
 MOV TMOD,#01H
 MAIN:CPL P0.0
 ACALL DELAY
 SJMP MAIN
 
 DELAY:MOV TH0,#FFH
 MOV TL0,#F5H
 SETB TR0
 LABEL2:JNB TF0,LABEL2
 CLR TR0
 CLR TF0
 RET









































Serial Tx


#include <LiquidCrystal.h>
const char *msg="Hello World !";

const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  pinMode(8,OUTPUT);
  lcd.begin(16, 2);
 
  lcd.print(msg);
   
   
  
   
    for(int bytedata=0;bytedata<strlen(msg);bytedata++)
   
    {
       
    char txbyte=msg[bytedata];
       
        lcd.setCursor(0,1);//clr for sec
    lcd.print("        ");
   
       
       
       
        for(int bitdata=0;bitdata<8;bitdata++)
       
        {
           
        bool txbit=txbyte &(0x80>>bitdata);
            digitalWrite(8,txbit);
           
            lcd.setCursor(bitdata,1);
            lcd.print(txbit ? "1" : "0");
            delay(40);
           // lcd.clear();
        }
       
       
    }
   
   
   
}

void loop()
{
 
 
 
}













Previous Post Next Post