??? 05/25/06 07:19 Modified: 05/25/06 09:05 Read: times |
#117068 - Problem on a code |
I built a circuit with a sensor, which sends information to port 0 of the 8051 through an A/D. the code needs to check the port and see if the voltage (That I put into the Acc) is less/equal/bigger than 101010(binary). If it's smaller, to call the func. OK, if it's bigger or equal, call bip.
This is the code: org 0000h ljmp 0100h AD_OUTPUTS EQU P0 ; DB0 to DB7 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.7 ; MICROPHONE AD_SC BIT P2.4 ; start conversion AD_EOC BIT P2.6 ; end of conversion ;;;;;;;;;;;;;;;;;;;;;;;;?????;;;;;;;;;;;;;;;;;;;;;;;; int: ;--INITIALIZE A/D clr AD_OE clr AD_ALE clr AD_CLK lcall START_CONV begin: 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_CLK,START_CLK ;if the clock variable is 0, return back and set it to one. if it's one, continue. (was EOC) setb AD_OE mov a,AD_OUTPUTS clr AD_OE ret Compare: CJNE A,#101010b,acc_ne JMP acc_equal acc_ne: jc acc_small jmp acc_large acc_equal: lcall bip jmp begin acc_small: call ok jmp begin acc_large: lcall bip jmp begin ok: setb phone jmp begin jmp begin bip: clr phone jmp begin END I've tried almost 20 different simulators and no one worked.. Thank you very much, Ofir Epstein. |
Topic | Author | Date |
Problem on a code | 01/01/70 00:00 | |
clean up | 01/01/70 00:00 | |
Thanks | 01/01/70 00:00 | |
Still doesn't work.. | 01/01/70 00:00 | |
evidence | 01/01/70 00:00 | |
What about open collector on port 0? | 01/01/70 00:00 | |
Various problems | 01/01/70 00:00 | |
How to post code | 01/01/70 00:00 | |
20 different simulators![]() | 01/01/70 00:00 |