Posted on Leave a comment

Easy!

 

8051 UART, interrupts:

   Serial data from of 1st microchip At89s52 transmit through pin P3.1, then received by pin P3.0 of 2nd microchip

   Baud rate 9600Hz by used crystal 11.0592MHz, time1 in mode 2

   11.0592Mhz/12 is machine cycle frequency

   11.0592Mhz/12/32 is bits per second of UART=28800bps

   To get 9600bps, need 3 cycles to overflows =>256-3=FD

   Load TH1=FD

  Use a button to start transfer data, interrupt serial

Important note: have to setup up the same Xtal 11.0592 in c, asm files, proteus simulation software.

asm files for transmit & reception:

 

asm file for transmit:

/* by Hoang N Tran*/
org 000h
   ljmp begin
org 23h
   ljmp CLR_TI
/*This file set up UART in mode 1 (8 bits UART) with
timer 1 in mode 2 */
org 0100h
begin:/* press button to transfer data*/
   JB P1.0,CLR_TI/* UART in mode 1 (8 bit), REN=1 */
   MOV SCON, #50h
   ORL TMOD, #20h
    MOV TH1, #0FDh
/* Timer 1 in mode 2 *//* 9600 bds at 11.059MHz */
   MOV TL1, #0FDh
   SETB ES;
/* Enable serial interrupt*/
   SETB EA;
   SETB TR1/* Sent letter A to 2nd microchip */
   MOV SBUF,#65
/* endless */  JMP $CLR_TI:/*clear Transmation flag for next Transmation*/
   CLR TI 
   RETI
end

 

asm file for receive:

/* by Hoang N Tran*/

org 00h
   SJMP BEGIN
org 23h
   LJMP CLR_RI
DISLAY:
   SETB P2.0
   CLR P2.1
   SETB P2.2
   CALL DELAY
   CLR P2.2
   RET
DELAY:
   MOV R1,#0EFH
   LR1: DJNZ R1,LR1
   RET
BEGIN:

 /* UART in mode 1 (8 bit), REN=1 */
   MOV SCON, #50h
   ORL TMOD, #20h
   MOV TH1, #0FDh
/* Timer 1 in mode 2 */
/* 9600 Bds at 11.059MHz */
   MOV TL1, #0FDh
   SETB ES;
/* Enable serial interrupt*/
   SETB EA;
   SETB TR1;
   MOV P1,#38H
   CALL INNT
   MOV P1,#0EH
   CALL INNT
   MOV P1,#06H
   CALL INNT
   MOV P1,#01H
   CALL INNT
   MOV P1,#80H
   CALL INNT
   SJMP LED
INNT:
   CLR P2.0
   CLR P2.1
   SETB P2.2
   CALL DELAY
   CLR P2.2
   CALL DELAY
   RET

LED:

/*Receive letter A from 1st microchip*/
   MOV B,SBUF
   JNB 0F0H,LED
   MOV P1,#32
   CALL DISLAY
   MOV P1,#32
   CALL DISLAY
   MOV P1,#32
   CALL DISLAY

   MOV P1,SBUF 
   CALL DISLAY
   MOV P1,#116
   CALL DISLAY
   MOV P1,#56
  CALL DISLAY

   MOV P1,#57
   CALL DISLAY
   MOV P1,#115
   CALL DISLAY
   MOV P1,#53
   CALL DISLAY
   MOV P1,#50
   CALL DISLAY

   JMP $

CLR_RI:
   MOV P0,SBUF
   CLR RI
   RETI
END

c files for transmit & reception:

 c file for transmit:

/* by Hoang N Tran */
#include <REGX51.H>
void UART_Init(){
   TMOD = 0x20; /* Timer 1, 8-bit auto reload mode */
   TH1 = 0xFD; /* Load value for 9600 baud rate */
   SCON = 0x50; /* Mode 1, reception enable */
   TR1 = 1; /* Start timer 1 */
}void Transmit_data(char char_data){
   SBUF = char_data; /* Load char in SBUF register */
   while (TI==0); /* Wait until stop bit transmit */
   TI = 0; /* Clear TI flag */
}

void String(char *str){
/* Send each char of string till the NULL */
   int i;
    for(i=0;str[i]!=0;i++) {
    Transmit_data(str[i]); }
}

void main(){

/* press button to transmit data*/

   while(P1_0==1);

/* UART initialize function */
   UART_Init();

/* Transmit  a string */

   String(“This’s At89s52 Hello KHANH”);

while(1);
}

 

c file for receive:

/* by Hoang N Tran*/
#include <REGX51.H>
int y,n;
char x[16];
char t[16];
/* delay approx 1ms */
void delay(unsigned int count){
int i,j;
for(i=0;i<count;i++)
for(j=0;j<112;j++);
}
/* LCD16x2 command funtion */
void LCD_Command (unsigned char cmd){
P1= cmd;/* P1 port as data port */
P2_0=0; /* RS pin */
P2_1=0; /* RW pin */
P2_2=1; /*E pin */
delay(1);
P2_2=0;
delay(5);
}
/* LCD data write function */
void LCD_Char (unsigned char char_data){
P1=char_data;
P2_0=1;
P2_1=0;
P2_2=1;
delay(1);
P2_2=0;
delay(5);
}
/* Send each char of string till the NULL */
void LCD_String (unsigned char *str){
int i;
for(i=0;str[i]!=0;i++)
{
LCD_Char (str[i]); /* Call LCD data write */
}
}void LCD_Init (void) /* LCD Initialize function */
{
delay(20); /* time >15ms to LCD ON*/
LCD_Command (0x38); /* Initialization of 16X2 LCD in 8bit mode */
LCD_Command (0x0E); /* Display ON Cursor*/
LCD_Command (0x06); /* Auto Increment cursor */
LCD_Command (0x01); /* clear display */
LCD_Command (0x80); /* cursor at home position */}void Ext_int_Init()
{
EA = 1; /* Enable global interrupt */
ES = 1; /* Enable serial interrupt */
}void UART_Init()
{
TMOD = 0x20; /* Timer 1, 8-bit auto reload mode */
TH1 = 0xFD; /* Load value for 9600 baud rate */
SCON = 0x50; /* Mode 1, reception enable */
TR1 = 1; /* Start timer 1 */
}void Serial_ISR() interrupt 4
{
if (y<=13)x[y]=SBUF;
if (y>13) {t[n]=SBUF;n++;}
y++;
RI = 0;
}void main(){
P0_0=1;
Ext_int_Init(); /* Call Ext. interrupt initialize */
UART_Init();/* UART initialize function */
while(RI==0);/* waiting for received data on port 1 */
LCD_Init(); /* initialization of LCD*/
P0=x[0];
LCD_String(x);
LCD_Command(0xC0);
LCD_String(t);
while(1);
}
Posted on Leave a comment

At89s52 assembler

 

asm file for at89s52, Xtal 12Mhz:

org 00h
   MOV P1,#00H
   MOV P3,00H
   MOV P2,#00H
org 09H
   CPL 90H
   ACALL 13H
   CPL 90h
   ACALL 13H
   SJMP 08h
org 13h
   MOV R3,#021H
org 15h
   MOV R2,#0FFH
org 17h
   MOV R1,#70H
org 19h
   DJNZ R1,19h
   DJNZ R2, 17h
   DJNZ R3, 15h
   RETend

 

How to move website:

To save or move a website, need only to export database of the old website from host and download folder public_html of the old website, store in anywhere.

 For example to move a domain, host nearly expired to new:

1/Create new MySQL database and database user in  new host, add the new website to host then pointing website to database by edit wp-options in PhpMyAdmin, not install WordPress.

2/Upload folder public_html.zip to /files/ of new website, then extract to folder public_html, should delete files, folder sample.

3/Connect new website to new database by retype DB_user, DB_name, DB_pw in file public_html/wp-config.php. Login wp-admin by the old user, pw to post.