Switch to full style
PIC Assembly Articles
Post a reply

ramp Counter ANALOGUE TO DIGITAL CONVERSION (ADC)

Thu May 16, 2013 4:37 pm

ramp Counter ANALOGUE TO DIGITAL CONVERSION (ADC)
Code:
list 16f877
include <p16f877.inc>
BANK0 macro
bcf STATUS
,RP0
bcf STATUS
,RP1
endm

BANK1 macro
bsf STATUS
,RP0
bcf STATUS
,RP1
endm

BANK2 macro
bcf STATUS
,RP0
bsf STATUS
,RP1
endm

BANK3 macro
bsf STATUS
,RP0
bsf STATUS
,RP1
endm

COUNT EQU 0x22 
;USED FOR COUNTING
RESULT EQU 0x23


ORG 0
NOP
GOTO START
ORG 0x20

START CALL INIT
REPEAT CLRF COUNT 
;SET COUNT TO ZERO
RAMP MOVF COUNT
,;GET COUNT vALUE
MOVWF PORTD 
;AND OUTPUT TO DAC
BTFSC PORTA
,;TEST COMP OUTPUT
GOTO DONE 
;IF NOT ZERo
CoNVERS ION CoMPLETE
INCF COUNT 
;COtINT UP
GOTO RAMP 
;RAMP UP

DONE MOVF COUNT
,;GET COUNT
MOVWF RESULT 
;AND STORE
GOTO REPEAT 
;DO AGAIN

;PORT INIT ROUTINE
INIT BSF STATUS
,RP0 ;SET To BANK 1.
CLRF TRISD 
;SET PORT D To OUTPUT
MOVLW 06 
;MAKE PoRT A DIGITAL
MOVWF ADCON1
BSF TRISA
,;AND BIT A4 To INPUT
BCF STATUS
,RP0 ;BACK To BANK 0
RETURN
END




Post a reply
  Related Posts  to : ramp Counter ANALOGUE TO DIGITAL CONVERSION (ADC)
 SUCCESSIVE APPROXIMATION ANALOGUE TO DIGITAL CONVERSION     -  
 The Digital to Analogue converter DAC writer     -  
 digital watermark on image     -  
 .dll conversion     -  
 Type Conversion     -  
 Number Conversion     -  
 please get me the following Delphi to Java conversion     -  
 jsp page counter     -  
 File page counter in php     -