PICF819 Analog/Digital settings

Discussion in 'Embedded Systems and Microcontrollers' started by ronbowalker, Nov 17, 2009.

  1. ronbowalker

    Thread Starter Member

    Jun 26, 2009
    23
    0
    I am using a PIC16F819 and I am not sure what the proper settings are to make all the I/O pin Digital. I see that some of the pins are designated as Analog, but does this mean that they cannot be Digital? I am rookie on this part and this is a new chip for me. 31kHz and Digital Inputs mostly.
    Please help if you can, thanks.
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    They can be digital or analog. See section 11 of the datasheet. You have to change some bits in ADCON0 and ADCON1
     
  3. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    IF you read through the datasheet... it actually gives you examples on how to do this.....

    Code ( (Unknown Language)):
    1.  
    2. BANKSEL PORTA     ; select bank of PORTA
    3. CLRF PORTA          ; Initialize PORTA by clearing output data latches
    4. BANKSEL ADCON1   ; Select Bank of ADCON1
    5. MOVLW 0x06         ; Configure all pins
    6. MOVWF ADCON1    ; as digital inputs
    7. MOVLW 0xFF         ; Value used to initialize data direction
    8. MOVWF TRISA       ; Set RA<7:0> as inp
    9.  

    My .02
     
  4. ronbowalker

    Thread Starter Member

    Jun 26, 2009
    23
    0
    Thank you for the lesson. I see what you are talking about now. This should be what I need. I have another question about another issue I just encountered. I thought the PIC16F819 had an Internal OSC. But it is a "Block" in the datasheet description. Is this still an internal oscillator that will do 32kHz? I am trying to save power as well as pcb space, and I was hoping to not use RC. I hope you can help me with this.
     
  5. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    • Internal oscillator block:
    - 8 user selectable frequencies: 31 kHz, 125 kHz,
    250 kHz, 500 kHz, 1 MHz, 2 MHz, 4 MHz, 8 MHz


    I don't see where it says anything about 32Khz........ 31Khz but not 32.....
     
  6. ronbowalker

    Thread Starter Member

    Jun 26, 2009
    23
    0
    My bad, I meant 31kHz...sorry
     
  7. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234

    Then, Yes it can do 31Khz with internal osc....
     
  8. ronbowalker

    Thread Starter Member

    Jun 26, 2009
    23
    0
    Here are my programmer configuration. I am using Pic Basic Pro.

    Oscillator: INTRC(INTIO2)
    WTD: Enabled
    Power-Up Timer: Enabled
    MCLR Pin Function: Reset
    Brown-Out Reset: Enabled
    Low Voltage Programming: Disabled
    CCP Multiplexed With: RB2
    Flash Program Memory Write Enabled: All
    Code: Not Protected
    Data EEPROM: Not Protected
     
  9. ronbowalker

    Thread Starter Member

    Jun 26, 2009
    23
    0
    This is in long form for me to follow my setting easier as I get this programing under way. Chip is running at 87uA with this loaded. But no pins are High(B.0 & A.7 should be)

    '***INITIALIZATION and SETTINGS***********************
    DEFINE OSC 3 'Frequency in Mhz (TBD)
    OSCCON = %00001000 'Internal Oscillator @ 32kHz
    ADCON1=7 'Makes input Digital (not Analog)
    ''''''''''''''''''''''''''PIN SETTINGS''''''''''''''''''''''''''''''''''''
    'BUTTON..............WHITE
    TRISA.6 = 1 'Input (White button)
    PORTA.6 = 0 'LOW (WHite button)
    'BUTTON..............GREEN
    TRISB.6 = 1 'Input (Green button)
    PORTB.6 = 0 'LOW (Green button)
    'BUTTON..............RED
    TRISA.4 = 1 'Input (Red button)
    PORTA.4 = 0 'LOW (Red button)
    'BUTTON..............BLUE
    TRISA.2 = 1 'Input (Blue button)
    PORTA.2 = 0 'LOW (Blue button)&(serial)
    'LED.................WHITE
    TRISA.5 = 0 'Output (White LED)
    PORTA.5 = 0 'LOW (White LED)
    'LED.................GREEN
    TRISB.4 = 0 'Output (Green LED)
    PORTB.4 = 0 'LOW (Green LED)
    'LED.................RED
    TRISB.2 = 0 'Output (Red LED)
    PORTB.2 = 0 'LOW (Red LED)
    'LED.................BLUE
    TRISB.3 = 0 'Output (Blue LED)
    PORTB.3 = 0 'LOW (Blue LED)&(serial)
    'Relays....................
    TRISB.0 = 0 'Output (Bulb-Out 1 call)
    PORTB.0 = 1 'HIGH (Bulb-Out 1 call)

    TRISA.7 = 0 'Output (Bulb-Out 2 call)
    PORTA.7 = 1 'HIGH (Bulb-Out 2 call)

    TRISB.1 = 0 'Output (PB1 call)
    PORTB.1 = 0 'LOW (PB1 call)

    TRISA.3 = 0 'Output (PB2 call)
    PORTA.3 = 0 'LOW (PB2 call)

    TRISA.0 = 0 'Output (SPARE)
    PORTA.0 = 0 'LOW (SPARE)

    TRISA.1 = 0 'Output (SPARE)
    PORTA.1 = 0 'LOW (SPARE)

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     
Loading...