Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

assembly language terms

Status
Not open for further replies.

hoongbok

Electrical
Jan 29, 2002
10
i currently doing a project on microcontroller 8031 and testing a program 'pulse width measurement' from a book "the 8051 microcontroller architecture, programming, and application"... but i don't understand the terms least significant bytes and most significant byte...some one can help...i can post the source code ....pls help tq..
 
Replies continue below

Recommended for you

16 bits are broken up into 2 bytes (each 8 bits long). The least signifigant byte contains the lower 8 bits while the most signifigant byte contains the upper 8 bits.
 
thank you for your reply melone,
but i still very blur by what kind of information is stored inside the P1 and P2 in the below program code....

.equ wflg,00h ;bit flag used to notify main program
.org 0000h
mov sp,#30h ; set stack above bit addreeable area
sjmp over ;jump over INT1 interrupt area

;place /INT1 interrupt routine here
.org 13h
jb int1,noise ;if not low then noise --leave
jbc tr1,stop ;if T1 is running then stop it
setb tr1 ;if T1 is notrunning then start it

noise:
reti ;return with T1 enabled to time pulse

stop:
setb wflg ;set flag to indicate measurement done
clr ex1 ;disable INT1 until next measurement
reti ;return with T1 stopped and wflg set

;the main program is placed here. the program monitors wflg and display the high pulse width on P1 (LSBY) and P2 (MSBY).
;the width is accurate to the nearest microsecond

over:
mov tmod,#90h ;T1 to count when INT1 pin high
setb it1 ;INT1 interrupt on negative edge
mov tl1,#00h ;reset T1 to 00h
mov th1,#00h
mov ie,#84h ;enable global and INT1 interrupts

simulate:
jbc wflg,getwidth ; test flag til measurement made
sjmp simulate ; loop til finish

getwidth:
mov p1,tl1 ;display LS Byte on P1
Mov p2,th1 ;display MS byte on P2
sjmp over
.end

so in the last part of the code in the "getwidth" part...how the pulse width in milisecond can be save into P1 (port 1)and P2(port2)...i mean in what form...let's say for example pulse width with 45.6milisecond...how it gonna to be kept in the MSB and LSB onto P1 and P2? help, anyone..

cheers,
bok



 
Hi, assuming you are counting in 1us. Then 45.6ms = 45,600 counts,as the counter is a binary this results in a a hex count of 0xb220. So p2 will have 0xb2 and p1 will have 0x20.
 
hi, thank you for your reply...but can you please give me a few example... such as like 240ms = 240,000us = 3a890H so what is the Msb and Lsb, is that the Msb=3a and LSB= 90..is this the answer? thank you for your helps...
thanks,
bok
 
Hi, the counter is only 16 bit therefore you can only count up to 0xffff thats 65535 decimal.If you count more then the counter overflows and counts from zero.so if you try to count 240000 ie hex 0x3a980 then you only keep the lower 16 bits ie 0xa980, so p2 will have 0xa9 and p1 will have 0x80.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor