;----------------------------------------------------------------------------- ; 9/26/2002 sjd ; ; ; ; FILE NAME : ADC.ASM ; TARGET MCU : C8051F000 ; DESCRIPTION : This program illustrates how to configure the ; : ADC0 and Crossbar, read the ADC0 and write to the ; : port 2&3 I/O pins. Default values for ADC0. LED ; : displays used as indicators. ; ; ; NOTES: ; ; (1) This note intentionally left blank. ; ; ;----------------------------------------------------------------------------- ;----------------------------------------------------------------------------- ; EQUATES ;----------------------------------------------------------------------------- $include (c8051f000.inc) ; Include register definition file. ;----------------------------------------------------------------------------- ; VARIABLES ;----------------------------------------------------------------------------- ;----------------------------------------------------------------------------- ; RESET and INTERRUPT VECTORS ;----------------------------------------------------------------------------- ; Reset Vector cseg AT 0 ljmp Main ; Locate a jump to the start of code at ; the reset vector. ;----------------------------------------------------------------------------- ; CODE SEGMENT ;----------------------------------------------------------------------------- Code_Seg segment CODE rseg Code_Seg ; Switch to this code segment. using 0 ; Specify register bank for the following ; program code. ; Enable Vref - required before using adc Main: mov REF0CN, #00000011b ; bias on, int vref. mov R0, #0 ;clear R0 mov R1, #0 ;clear R1 ; ; Enable the Port I/O Crossbar mov XBR2, #40h ;P2,P3 set for output to LED displays. mov P2, R0 mov P3, R1 ;loop. Loop: mov ADC0CN, #10010000b mov R0, ADC0H mov R1, ADC0L mov P2, R0 ;write ADC0H value to port2 mov P3, R1 ;write ADC0L value to port3 jmp Loop ;----------------------------------------------------------------------------- ; End of file. END