Problem with ADC


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier
    For the first block of ASM, replace with

    PORTA = $10
    TRISABUF=$10
    OPTION_REG=$37

    You need to post the rest of your ASM code in order for us to see how to completely convert the second block (.i.e, where is your delay routine?)
    Code:
        FHI		    VAR BYTE
        FLO		    VAR BYTE
        COUNT1		VAR BYTE
        TRISABUF	VAR BYTE
        TEMPS		VAR BYTE
    All the ASM code

    Code:
    Asm
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;    AUTHORIZATION OF COUNTING
    
    	clrf	TMR0		        ; RAZ timer
    	bsf	_trisabuf,3		        ; RA4 in entry and RA3 in entry authorization counting
    	movf 	_trisabuf,W
    	tris	PORTA
    	
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;    BASE TIME  
          
    	movf	_TEMPS,W
            movwf	_COUNT1
    dxxx	nop
    	decfsz	_COUNT1
    	GoTo	dxxx
    	nop
    	nop
    	Call delay
    	Call delay
    	Call delay
    	Call delay
    	Call delay
    	
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;      STOP OF COUNTING
    
    	bcf	_trisabuf,3		        ;RA4 in entry and RA3 at Exit to block counting
    	movf 	_trisabuf,W         
    	tris	PORTA
    	
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;      RECUPERATION OF THE METERS
      
    calcul	MOVF    TMR0,W		    ;timer   -> work
    	MOVWF   _FHI	       	    ;work -> FHI	8 bits of weight strong counting
    	clrf	_COUNT1		        ;handing-over has zero meter
    Toggle	incf	_COUNT1,F	    ;incrementation of the meter
    	bsf	PORTA,3		            ;RA3 a 1
    	bcf	PORTA,3		            ;RA3 a 0
    	movf	TMR0,W		        ;reading of the timer
    	subwf	_FHI,w		        ;it is looked at if the divider incremente the timer
    	btfsc	STATUS,2		    ;comparison
    	GoTo	Toggle		        ;if the timer did not incremente one starts again
    	comf	_COUNT1,F	        ;complement with the meter
    	incf	_COUNT1,W	        ;incrementation of the meter
    	movwf	_FLO		        ;work -> FLO 	8 bits of weight weak counting
    	GoTo fin
    	
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;     BASE TIME 
      
    delay   	movlw	197         ;1ms according to AN592
    	movwf	_COUNT1          	
    	nop                     		
    	GoTo	$+1              		
    	GoTo	$+1             		
    dly	GoTo	$+1              		
    	decfsz	_COUNT1         	
    	GoTo	dly             		
    	Return		            	
    fin
    EndAsm
    Last edited by savnik; - 22nd November 2006 at 21:35.

Similar Threads

  1. pic12f675 ADC problem
    By radu022003 in forum mel PIC BASIC
    Replies: 3
    Last Post: - 1st September 2009, 10:13
  2. PIC18F2423, ADC problem
    By mistergh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th March 2009, 01:31
  3. Mutliple ADC problem with PIC16F877
    By andyto in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2007, 17:47
  4. ADC problem with PIC16F917
    By eetech in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th March 2007, 21:22
  5. Problem reading multiple ADC ports
    By jswayze in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2004, 16:46

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts