can any one help me in understanding the follwing rf transmitter code using at89c51
0373 C4 259 SWAP A
0374 54F0 260 ANL A,#0F0H
0376 F5F0 261 MOV B,A
0378 E571 262 MOV A,RAM2
037A C3 263 CLR C
037B 9430 264 SUBB A,#30H
037D 25F0 265 ADD A,B
037F F560 266 MOV PACK1,A
i've got this from the net but i have a bit of problem in understanding it.......
it is uart communication
RU1: MOV A,RAM1 SWAP A ANL A,#0F0H MOV B,A ; saves lower nibble of RAM1 in B as only 4-higher bits (upper nibble) .. MOV A,RAM2 CLR C SUBB A,#30H ; most likely converts RAM2 from ASCII to HEX ADD A,B ; adds both together MOV PACK1,A ; and saves in PACK1
[/COLOR]hey Ianp can u help me with this part .is it manchester coding or something else......
program is on rf data transmission using uart communication
MOV A,RAM2
CLR C
SUBB A,#30H ; most likely converts RAM2 from ASCII to HEX
ADD A,B ; adds both together
MOV PACK1,A ; and saves in PACK1
To answer your question one needs to know what was saved in RAM1, as from this fragment of the code it looks like SUB A, #30h just extracts a number (0-9) coded in ASCII and saved in RAM2 ..
Without knowing what happened before it?s difficult to guess ..
IanP
hey Ianp i m sending u the whole assembly code........plz help me out with this...........i'm totlaay screwed with the data transmission part.......not able to get whats is happeneing
;"Wireless Automation Control System"
4
DB0 EQU P1.0
DB1 EQU P1.1
DB2 EQU P1.2
DB3 EQU P1.3
DB4 EQU P1.4
DB5 EQU P1.5
DB6 EQU P1.6
DB7 EQU P1.7
EN EQU P3.4
RW EQU P3.3
RS EQU P3.2
UP EQU P2.0
DOWN EQU P2.1
ENT EQU P2.2
RUN EQU P2.3
DATA1 EQU P1
PACK1 EQU 60H
PACK2 EQU 61H
PACK3 EQU 62H
PACK4 EQU 63H
RAM1 EQU 70H
RAM2 EQU 71H
RAM3 EQU 72H
RAM4 EQU 73H
RAM5 EQU 74H
RAM6 EQU 75H
RAM7 EQU 76H
RAM8 EQU 77H
ORG 00H
LJMP MAIN
ORG 150H
MAIN: SETB P0.4
MOV P0,#1FH
MOV P0,#0FH
SETB P0.4
MOV P0,#10H
MOV P0,#00H
SETB P0.4
LCALL INIT_LCD ;LCD Initialization
MOV A,#80H
LCALL CMD
MOV A,#'P'
LCALL WRITE_TEXT
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
LCALL WRITE_TEXT
MOV A,#'A'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
MOV A,#'Y'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'K'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#'Y'
LCALL WRITE_TEXT
MOV A,#'!'
LCALL WRITE_TEXT
MOV A,#'!'
LCALL WRITE_TEXT
MOV A,#'!'
LCALL WRITE_TEXT
SETB P0.4
MOV P2,#0FFH ;P2 AS INPUT
MOV A,P2 ;READ P2
ANL A,#0FH
JZ KEEP
LCALL DELAY ;Debounce check
MOV A,P2
ANL A,#0FH
JZ KEEP
LCALL CLEAR_LCD
MOV A,#80H ;set cursor to frist position.
LCALL CMD
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'I'
LCALL WRITE_TEXT
MOV A,#'M'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'U'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
NOP
NOP
NOP
NOP
NOP
NOP
NOP
MOV A,#0C0H
LCALL CMD
LCALL WAIT_LCD
MOV A,#'P'
LCALL WRITE_TEXT
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'!'
LCALL WRITE_TEXT
MOV A,#'E'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'!'
LCALL WRITE_TEXT
H1: JB ENT,G1
SJMP H1
G1: LCALL DELAY
JB ENT,T_SET_D
SJMP H1
T_SET_D: LCALL CLEAR_LCD
MOV A,#80H ;set cursor to frist position.
LCALL CMD
MOV A,#'D'
LCALL WRITE_TEXT
MOV A,#'1'
LCALL WRITE_TEXT
MOV A,#'_'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'='
LCALL WRITE_TEXT
MOV A,#88H
LCALL CMD
MOV A,#'D'
LCALL WRITE_TEXT
MOV A,#'2'
LCALL WRITE_TEXT
MOV A,#'_'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'='
LCALL WRITE_TEXT
MOV A,#0C0H
LCALL CMD
MOV A,#'D'
LCALL WRITE_TEXT
MOV A,#'3'
LCALL WRITE_TEXT
MOV A,#'_'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'='
LCALL WRITE_TEXT
MOV A,#0C8H
LCALL CMD
MOV A,#'D'
LCALL WRITE_TEXT
MOV A,#'4'
LCALL WRITE_TEXT
MOV A,#'_'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'='
LCALL WRITE_TEXT
H2: JB ENT,G2
SJMP H2
G2: LCALL DELAY
JB ENT,STIME
SJMP H2
STIME: MOV A,#85H ;SET CURSOR TO L=1,P=5
LCALL CMD
LCALL UP_DOWN
MOV RAM1,A ;D_1
MOV A,#86H
LCALL CMD
LCALL WAIT_LCD
LCALL UP_DOWN
MOV RAM2,A ;D_1
MOV A,#8DH
LCALL CMD
LCALL WAIT_LCD
LCALL UP_DOWN
MOV RAM3,A ;D_2
MOV A,#8EH
LCALL CMD
LCALL WAIT_LCD
LCALL UP_DOWN
MOV RAM4,A ;D_2
MOV A,#0C5H
LCALL CMD
LCALL WAIT_LCD
LCALL UP_DOWN
MOV RAM5,A ;D_3
MOV A,#0C6H
LCALL CMD
LCALL WAIT_LCD
LCALL UP_DOWN
MOV RAM6,A ;D_3
MOV A,#0CDH
LCALL CMD
LCALL WAIT_LCD
LCALL UP_DOWN
MOV RAM7,A ;D_4
MOV A,#0CEH
LCALL CMD
LCALL WAIT_LCD
LCALL UP_DOWN
MOV RAM8,A
MOV P2,#0FFH
H3: JB RUN,G4
SJMP H3
G4: LCALL DELAY
JB RUN,RU1
SJMP H3
RU1: MOV A,RAM1
SWAP A
ANL A,#0F0H
MOV B,A
MOV A,RAM2
CLR C
SUBB A,#30H
ADD A,B
MOV PACK1,A
MOV A,RAM3
SWAP A
ANL A,#0F0H
MOV B,A
MOV A,RAM4
CLR C
SUBB A,#30H
ADD A,B
MOV PACK2,A
MOV A,RAM5
SWAP A
ANL A,#0F0H
MOV B,A
MOV A,RAM6
CLR C
SUBB A,#30H
ADD A,B
MOV PACK3,A
MOV A,RAM7
SWAP A
ANL A,#0F0H
MOV B,A
MOV A,RAM8
CLR C
SUBB A,#30H
ADD A,B
MOV PACK4,A
MOV A,PACK1 ;DECI TO HEX SUB..FOR R0
MOV R4,A
LCALL D_T_H
MOV PACK1,A
MOV A,PACK2 ;FOR R1
MOV R4,A
LCALL D_T_H
MOV PACK2,A
MOV A,PACK3 ;FOR R2
MOV R4,A
LCALL D_T_H
MOV PACK3,A
MOV A,PACK4 ;FOR R3
MOV R4,A
LCALL D_T_H
MOV PACK4,A
NOP
MOV R0,#99
MOV R6,#00H ;DEVICE CONTROL SUB
MOV P0,#0FH ;All Devices On p1=00
L1: LCALL TIMER
INC R6
MOV A,R6
CJNE A,PACK1,D1
CLR P0.0
MOV A,#85H ;SET CURSOR TO L
LCALL CMD
MOV A,#24H
LCALL WRITE_TEXT
MOV A,#24H
LCALL WRITE_TEXT
MOV A,R6
D1: CJNE A,PACK2,D2
CLR P0.1
MOV A,#8DH ;SET CURSOR TO L
LCALL CMD
MOV A,#24H
LCALL WRITE_TEXT
MOV A,#24H
LCALL WRITE_TEXT
MOV A,R6
D2: CJNE A,PACK3,D3
CLR P0.2
MOV A,#0C5H ;SET CURSOR TO L
LCALL CMD
MOV A,#24H
LCALL WRITE_TEXT
MOV A,#24H
LCALL WRITE_TEXT
MOV A,R6
D3: CJNE A,PACK4,D4
CLR P0.3
MOV A,#0CDH ;SET CURSOR TO L=1,P=5
LCALL CMD
MOV A,#24H
LCALL WRITE_TEXT
MOV A,#24H
LCALL WRITE_TEXT
MOV A,R6
D4: DJNZ R0,L1
MoV P0,#00H
MOV P0,#1FH
LCALL CLEAR_LCD
MOV A,#82H ;set cursor to frist position.
LCALL CMD
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#'H'
LCALL WRITE_TEXT
MOV A,#'A'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'Y'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'U'
LCALL WRITE_TEXT
MOV A,#0CH
LCALL CMD
LJMP EXIT
INIT_LCD: MOV A,#38H ;LCD Initialization
LCALL CMD ;2 lines 5x7 matrix
A,#0EH
LCALL CMD ;Display On,Cursor On
MOV A,#06H
LCALL CMD ;Increment Cursor
RET
CMD: LCALL WAIT_LCD
CLR RS
MOV DATA1,A
CLR RW
SETB EN
LCALL DELAY
CLR EN
RET
WAIT_LCD: SETB DB7 ;P1.7 AS INPUT
CLR RS ;RS=0
SETB RW ;R/W=1 TO READ
BACK: CLR EN ;E=0
LCALL DELAY
SETB EN ;E=1
JB DB7,BACK ;STAY UNTIL BUSY FLAG=0
RET
DELAY: MOV R2,#37H
AGAIN: MOV R3,#225H
HERE1: NOP
NOP
DJNZ R3,HERE1
DJNZ R2,AGAIN
RET
CLEAR_LCD: MOV A,#01H ;
Clear LCD Sub-routine
LCALL CMD ;Clear LCD
RET
WRITE_TEXT: LCALL WAIT_LCD
SETB RS ;Data Write On LCD Sub-Routine
CLR RW
MOV DATA1,A
SETB EN
LCALL DELAY
CLR EN
RET
UP_DOWN: NOP
S2: MOV A,#'0'
S1: LCALL WRITE_TEXT
LCALL DELAY
LO1: JB UP,G3
JB DOWN,G3
JB ENT,G3
SJMP LO1
G3: LCALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
LCALL DELAY
NOP
JB UP,IN1
JB DOWN,DE1
JB ENT,ST1
SJMP LO1
IN1: MOV R5,A ;MOV ACC. TO R5
MOV A,#10H
LCALL CMD ;mOVE CURSOR LEFT
MOV A,R5
INC A
CJNE A,#3AH,S1
SJMP S2
DE1: MOV R5,A
MOV A,#10H
LCALL CMD
MOV A,R5
DEC A
CJNE A,#2FH,S1
SJMP S2
D_T_H: ANL A,#0F0H
SWAP A
MOV R5,A
JZ NOCHANGE
MOV A,#00H
AG: ADD A,#06H
DJNZ R5,AG
MOV R6,A
MOV A,R4
CLR C
SUBB A,R6
RET
NOCHANGE: MOV A,R4
RET
TIMER: MOV R7,#14H ;Timer time=50ms and loop=14H=20D
MOV TMOD,#10H ;Timer 0 mode 1(16 - bit)
REP: MOV TL1,#0FEH ;TL0=4b, Low byte
MOV TH1,#4BH
SETB TR1 ;Start Timer 0
CLR TR1 ;Stop Timer 0
CLR TF1 ;Clear Timer 0 flag for next round
DJNZ R7,REP ;Jump for Loop
EXIT: NOP
SJMP EXIT
NOP
END
RU1: MOV A,RAM1 SWAP A ANL A,#0F0H MOV B,A MOV A,RAM2 CLR C SUBB A,#30H ADD A,B MOV PACK1,A
---------- Post added at 04:14 ---------- Previous post was at 04:10 ----------
a7a6a5a4a3a2a1a0 SWAP A and #0F0 a3a2a1a0 0000 b7b6b5b4b3b2b1b0 SUBB A, #30 0000 b3b2b1b0 ADD A, B a3a2a1a0b3b2b1b0 = PACK1
hey i didn't understood why this merging of two data into pack1 in done......is it that in manchester coding each transmission bits require two bits
plz help me out.....
Why do you think it is some sort of coding, Manchester coding is totally different cattle of fish ..
Manchester code - Wikipedia, the free encyclopedia
Packing two numbers into one byte saves the number of used RAM locations and also if transmitted number of bytes to transmit ..
IanP
now this has confused me a lot.....why is there a usage of two RAMS for sending in one packet PACK1 and during the merging of two RAMS why do we get rid of the MSB's.....couldn't understand the logic behind it.....