Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/17/05 15:08
Read: times


 
Msg Score: -1
 -1 Non-Specific question
#95172 - 8051 µC code check
Hi,
I am using the P89C51RD2FA µC, and I wrote a code in the Assembler language.
Can someone check the code cuz It's not working and I need to know if it's the code:

;;;;;;;;;;;;;;;;;;;;;;;;??????:;;;;;;;;;;;;;;;;;;;;;;;;;;

AD_OUTPUTS EQU P0 ; DB0 to DB7
ADD_A BIT P2.0 ; 3 bit address
ADD_B BIT P2.1 ; 3 bit address
ADD_C BIT P2.2 ; 3 bit address
AD_CLK BIT P2.3 ; clock
AD_ALE BIT P2.4 ; address latch enable: to enable that one of the inputs will start recieving information.
AD_OE BIT P2.5 ; output enable
PHONE BIT P2.6 ; MICROPHONE
AD_SC BIT P2.4 ; start conversion
AD_EOC BIT P2.7 ; end of conversion

;;;;;;;;;;;;;;;;;;;;;;;;?????;;;;;;;;;;;;;;;;;;;;;;;;
begin:
;--INITIALIZE A/D
clr AD_OE
clr AD_ALE
clr AD_CLK


clr ADD_A ;OPEN INPUT 0
clr ADD_B
clr ADD_C


lcall START_CONV
lcall compare
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;FUNCTIONS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

START_CONV:

mov AD_OUTPUTS,#0ffh

clr AD_OE ; enabling the A/D send information

setb AD_ALE ; start converter [SET both Start Conversion (SC) and Address Latch Enable (ALE)]

clr AD_ALE ; start converter [SET both Start Conversion (SC) and Address Latch Enable (ALE)]



START_CLK:

cpl AD_CLK ;change the clock variable

jnb AD_EOC,START_CLK ;if the clock variable is 0, return back and set it to one. if it's one, continue.

; jb AD_EOC,START_CLK ;

setb AD_OE
mov a,AD_OUTPUTS
clr AD_OE
ret



Compare: ; compares if the Accumulator is between 352 mA to 372mA, and if it is, it bips.

CLR C

PUSH Acc ;have acc backed up
SUBB A,#10011b
POP Acc ;restore acc value

JNC acc_large
CJNE A,#10011b,acc_small
JMP acc_equal



acc_equal: lcall bip
ljmp begin
acc_small:
CLR C

PUSH Acc ;have acc backed up
SUBB A,#10010b
POP Acc ;restore acc value

JNC ok ;distanse is OK. (Acc is between 352mA to 372mA)

CJNE A,#10010b,acc_small2

JMP acc_equal
ljmp begin
acc_large: lcall bip
ljmp begin
ok: setb phone
ljmp begin
acc_small2: LCALL bip
ljmp begin
bip:
clr phone
ret

END


thanks,
Ofir.

List of 5 messages in thread
TopicAuthorDate
8051 µC code check            01/01/70 00:00      
   cuz no answer cuz            01/01/70 00:00      
      cuz you need to READ the fucking manual            01/01/70 00:00      
   What does it do,what is it suposed to do            01/01/70 00:00      
   Debug it!            01/01/70 00:00      

Back to Subject List