• 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

    towlerg-21522

    FineLineIDE

    Thread Starter: normnet

    Coming soon a new IDE: FineLineIDE! Features include:<O:p</O:p Bracket lines linking If-Endif, For-Next etc.<O:p</O:p Tabbed explorer so...

    towlerg Yesterday, 13:36 Go to last post
    Henk57-24049

    Compiler 3.6.1.7 issue with 16F1829 and I2C-LCD

    Thread Starter: Henk57

    Spend this afternoon with a compiler issue; no error's, but my LCD give only first line with squares, no characters, nothing. If I flash an old .hex...

    Henk57 Yesterday, 19:31 Go to last post
    hadv215-2509

    CData Table

    Thread Starter: Beginner

    Is there perhaps the possibility to extend the IDE with a 'Raw Flash' command? Currently I have the huge problem that if I want to program a web page...

    hadv215 Yesterday, 22:41 Go to last post
    Henk57-24049

    Pulse counter using COUNTER command

    Thread Starter: amod

    How I can use counter command for counting pulses on portd.3 of 16f877A.Iam making a 8 digit object counter.

    Henk57 Yesterday, 19:43 Go to last post