Dear all,
I am new to C8051 assembly language programming. To start off, my supervisor has tasked me to acquire DC signals into the ADC and store them in memory locations. The next phase will be interfacing with LCD.
I have fixed a DC variable voltage source from 0-3V into P1.7 of C8051F206 development board which I have configured as analog input. I will be using Port 3 for output.
I have tried to step through my program and I was able to see the values change at memory location 40H as I adjusted the input voltage for one time. When I tried to step through the second time, the system halted.
Could you share with me what I could do to allow the program run continuously and stores incoming dc values in several memory locations as I tuned my input voltage source?
My mediocre source code is as follow:
************* ;-Header File- ;************* $include (c8051f200.inc) ORG 0000H LJMP CONFIG ORG 0100H ;*************** ;-Configuration- ;*************** CONFIG: MOV PRT0MX,#004H ; PRT0MX: Initial Reset Value MOV PRT1MX,#000H ; PRT1MX: Initial Reset Value MOV PRT2MX,#000H ; PRT2MX: Initial Reset Value MOV P2MODE,#0FFH ; Set Port 2 as Input MOV P0MODE,#0FFH ; Set Port 0 as Input MOV P1MODE,#000H ; Set Port 1 as Analog input MOV PRT3CF,#000H ; Set Port 3 as Output CLR RS1 CLR RS0 ;******************* ;-ADC configuration- ;******************* MOV AMX0SL,#2FH ; Select Port 1.7 for analog use MOV ADC0CF,#80H ; 16 system clocks and 1 amp gain MOV ADC0CN,#0C1H ; ADC Control MOV REF0CN,#03H ; Use VDD as reference voltage ;*************** ;-Main Function- ;*************** MAIN: ACALL CONVERT ; Call subroutine "CONVERT" ;******************************************* ;-Convert Analog Signals to Digital Signals- ;******************************************* CONVERT: CLR ADCINT SETB ADBUSY ; Start Conversion ;****** ;-Poll- ;****** POLL: JNB ADCINT,POLL ; Poll to see whether conversion is done ;*********************************** ;-Store data in memory location- ;*********************************** STORE: MOV A,ADC0H MOV 40H,A RET END ; End of Program
Thank you for your advice in advance!