Adc in pic 18f65j50

Discussion in 'Embedded Systems and Microcontrollers' started by suhhh, Jan 5, 2012.

  1. suhhh

    Thread Starter New Member

    Jan 5, 2012
    1
    0
    HI

    In my project i am using pic 18f65j50 microcontroller to remotely monitor and control smps..As of now i've programmed ADC of Pic
    Pls tell me whether the codes are rite or wrong .The codes as given below

    Code ( (Unknown Language)):
    1.  
    2. LIST P = P18f65j50
    3.  INCLUDE"P18f65j50.INC"
    4.  
    5. CBLOCK 0X20
    6.  RESULT1
    7.  RESULT2
    8.  ENDC
    9.  ORG   0X00
    10.  NOP  
    11.  CALL   START
    12.  CALL   ACTION
    13.  
    14.  
    15.  
    16. START
    17.   CLRF  PORTA  
    18.  MOVLW B'00001011'
    19.  MOVWF TRISA,
    20.  BSF WDTCON,ADSHR
    21.  BCF ANCON0,PCFG0
    22.  BCF ANCON0,PCFG1
    23.  BCF WDTCON,ADSHR  
    24.  CLRF TRISF
    25.  CLRF PORTF
    26.  CLRF TRISB
    27.  MOVLW B'01000100'
    28.  MOVWF ADCON0
    29.   MOVLW B'00000011'
    30.  MOVWF ADCON1
    31.  BSF ADCON0,ADON
    32.  BCF PIR1,ADIF
    33.     RETURN
    34. ACTION
    35.  CLRF IDLEN
    36.  NOP
    37.  SLEEP
    38.  BSF  ADCON0,GO  
    39.  BTFSC  ADCON0,GO
    40.  GOTO  $-2
    41.  BSF WDTCON,SWDTEN
    42.  BSF PIR1,ADIF  
    43.  MOVLB   B'0000010'    
    44.  MOVF  ADRESH,W,1
    45.  MOVWF  PORTF,1
    46.  MOVF  ADRESL,W,1
    47.  MOVWF  PORTB,1
    48.  RETLW  0  
    49. LAST
    50.  NOP
    51.  END
    52.  
    btw i have executed these codes in MPLAB AND the build was successded
    Thank u pplIn advance..
     
    Last edited by a moderator: Jan 5, 2012
Loading...