PIC18F14K50 ADC problem


+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2016
    Posts
    33

    Default PIC18F14K50 ADC problem

    Hello again!

    I am trying to get ADC working using AN7 pins but I keep getting zero for PORTC.7 and 20 when I use ADCIN 7.I am using a 24 MHz crystal.
    It worked with PIC18F2450 but doesn't work with PIC18F14K50.


    Here is my code:

    Code:
    DEFINE LOADER_USED 1
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_BAUD 115200
    DEFINE HSER_SPBRG 12
    DEFINE HSER_CLOERR 1
    
    DEFINE OSC 24
    
    ADCON0 = %00011100
    ADCON1 = %00000000
    ADCON2 = %10110101
    
    ANSEL = %10001000
    ANSELH = %00000011
    
    TRISC.4 = 0            'led RC4
    TRISC.6 = 1
    
    TRISC.0 = 0
    TRISC.1 = 1
    TRISB.5 = 1              'RX
    TRISB.7 = 0              'TX
    adcVal VAR Byte
    tx1 VAR PORTB.7
    rx1 VAR PORTB.5
       
    LED VAR PORTC.4   
    Pause 1000
    MoveX = 0
    mainloop:
        
       
       high LED
       Pause 1000 
       ADCIN 7, adcVal 
        HSEROUT[adcVal]
       low LED
       Pause 1000
       Pause 200
       Goto mainloop
    I thing the problem is configuration again.Would appropriate any help.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,731

    Default Re: PIC18F14K50 ADC problem

    Code:
    ADCON2 = %10110101

    adcin does not support acqt

    Code:
    ADCON2 = %10110101
    @24 MHz fosc/16 is out of specs use fosc/32


    Code:
    ADCIN 7, adcVal
    without setting any defines is asking for trouble





    DEFINE ADC_BITS 8
    DEFINE ADC_CLOCK 3 or 2

    DEFINE ADC_SAMPLEUS 50
    This is more entertaining than Free to Air TV

Similar Threads

  1. PIC18F14K50 and USBin
    By ybosco in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th November 2013, 04:52
  2. Pic18f14k50
    By JoeyWallice in forum mel PIC BASIC
    Replies: 2
    Last Post: - 23rd October 2012, 11:13
  3. Pic18f14k50
    By JoeyWallice in forum mel PIC BASIC
    Replies: 1
    Last Post: - 17th October 2012, 02:16
  4. ADC problem on 18F46K22 device using all 28 ADC pins
    By JimAvanti in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd February 2012, 20:22
  5. Pic18F14K50 when?
    By Free_Flow in forum PBP Wish List
    Replies: 16
    Last Post: - 17th August 2009, 02:36

Tags for this Thread

Posting Permissions

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