how to read 10 bit value of adc in pic 16f877a


Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Mar 2014
    Location
    Pakistan
    Posts
    19

    Default how to read 10 bit value of adc in pic 16f877a

    hello everyone I have this code and tried it and its working perfectly to read 8 bit value of an0 ,it shows 0 to 255 value on lcd but i am not being able to read 10bit value of channel please help
    To derieve 8 bit value my code is
    device is 16f877a
    Code:
    
    CLEAR
    DEFINE OSC 4 
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4 
    DEFINE LCD_RSREG PORTE 
    DEFINE LCD_RSBIT 0 
    DEFINE LCD_EREG PORTE
    DEFINE LCD_EBIT 1
    DEFINE LCD_LINES 2
    DEFINE LCD_BITS 4
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    
    
    Low porte.2
    pause 500
    
    
    DEFINE ADC_BTTS 8
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    
    
    TRISA = %11111111
    TRISD = %00000000
    ADCON1 = %00000111   'set port a digital
    
    A2D_VALUE0 VAR byte
    
    
    LCDOUT $FE, 1
    MAINLOOP:
    ADCIN 0, A2D_VALUE0
    
    
    LCDOUT $FE, $80, DEC A2D_VALUE0,
    PAUSE 10
    GOTO MAINLOOP
    END
    For ten bit value my code is below but it still shows 8 bit value ,please guide me to generate 10 bit value of AN0 channel

    Code:
    CLEAR
    DEFINE OSC 4 
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4 
    DEFINE LCD_RSREG PORTE 
    DEFINE LCD_RSBIT 0 
    DEFINE LCD_EREG PORTE
    DEFINE LCD_EBIT 1
    DEFINE LCD_LINES 2
    DEFINE LCD_BITS 4
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    
    
    Low porte.2
    pause 500
    
    
    DEFINE ADC_BTTS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    
    
    TRISA = %11111111
    TRISD = %00000000
    ADCON1 = %00000111   'set port a digital
    
    A2D_VALUE0 VAR WORD
    
    
    LCDOUT $FE, 1
    MAINLOOP:
    ADCIN 0, A2D_VALUE0
    
    
    LCDOUT $FE, $80, DEC A2D_VALUE0,
    PAUSE 10
    GOTO MAINLOOP
    END
    
    Last edited by Archangel; - 1st November 2014 at 19:12.

Similar Threads

  1. ADC and SEEPROM on 16F877A
    By Digitaldood in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 8th January 2013, 17:49
  2. Replies: 2
    Last Post: - 22nd May 2012, 06:45
  3. 12 bit or higher ADC on a PIC that works with PBP?
    By Brandon in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th November 2007, 17:19
  4. Flash PIC with 12 bit ADC
    By Steve_88 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th October 2007, 20:35
  5. Read the newbee threads, 16F877A no go.
    By BobbyA in forum mel PIC BASIC Pro
    Replies: 39
    Last Post: - 31st December 2006, 03:09

Members who have read this thread : 2

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