--- This is a test - only visible to admins ---
--- advertisement may go here ---
  • PicŪ Basic


  • PIC18F1320 - Using ADC - 10 bits

    PHP Code:
    PIC18F1320 to transmit data read by AN0 to PC at 115K,8N1 using the on chip EUSART


    Device 18F1320                                            
    ' Produce code for a 18F1320 
    Config file
    ' Using 10Mhz Crystal - set PLL x 4 (40Mhz internal clock) 
    MCLR disabled
    '
    XTAL = 40                                                          ' 
    40 Mhz Int Osc
    WATCHDOG 
    OFF                                   
    '
    '
    '
    'Baud Rate setup
    Declare HSERIAL_BAUD 115200             ' 
    115200 baud 
    Declare HSERIAL_RCSTA 010000    ' Sets the respective PICmicro hardware register RCSTA
    Declare HSERIAL_TXSTA 100100    ' 
    Sets the respective PICmicro hardware register  TXSTA
    Declare HSERIAL_CLEAR On                  ' Clear the overflow error bit before commencing a read 
    '
    '
    '
    ' ADC Setup
    '
    -------------
    Declare 
    ADIN_STIME 150                         ' Settling time 150uS
        ADCON0 = 000001                           ' 
    Chan Select AN0
        ADCON1 
    111110                           ' AN0 Analogue
        ADCON2 = 111110                           ' 
    Right justified20TADFosc/64
    '                                   
        ' 
    Declare variables                   
    '---------------------
    Dim ADCVALUE As Word                             ' 
    ADC reading
    '      
    '
    Setup Ports
    '-------------
        TRISA = 000011                                   ' 
    Set up IO PortA
        TRISB 
    111101                                   ' Set up IO PortB
    '
    '     
    '
    ReadADC:
         
    ADCVALUE ADIn 0                        ' Read ADC Chan 0
         HSerOut [DEC4 ADCVALUE, ","]         ' 
    Send 
         GoTo ReadADC                                                       
    ' Loop for ever
    '

    End 
    This article was originally published in forum thread: PIC18F1320 - Using ADC - 10 bits started by Dick Barton View original post
  • Recent Activity

    normnet-324

    PIC iPod wav player

    Thread Starter: normnet

    Coming in the next month or two a PIC iPod wav player. Plays 44k, 8 bit, stereo wav files from an SD card. Displays BMP pictures on a NOKIA 6100...

    normnet Today, 13:59 Go to last post
    teo-16018

    Frequency counter

    Thread Starter: teo

    Hello everybody Can someone help me with a piece of code to measure a frequency (1Hz to 160 Hz) precision two decimals. The result is transmitted...

    teo Yesterday, 17:43 Go to last post
    joesaliba-353

    Multiple functions by a single switch

    Thread Starter: amod

    Hi, How can I use multiple function by a single switch.I want to use 4 functions by a single switch.

    joesaliba Today, 09:19 Go to last post
    steyn-15336

    PickitPlus for Pickit2 and Pickit3 works well

    Thread Starter: leonj

    Hi Everyone, I have always had issues with Pickit2/Pickit3 and I'm glad to say they seem to all be solved now. I obtained PickitPlus from Even at...

    steyn Today, 09:34 Go to last post
    RGV250-614

    SD routines for 18F series

    Thread Starter: charliecoultas

    I've used the SD routines very successfully for the P24 chips, but now I need to attach an SD card to a 18F26K22. Do such routines exist and if...

    RGV250 Yesterday, 19:40 Go to last post