16F1826 cannot get MCLR to act as an INPUT


Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Jan 2009
    Posts
    50

    Default 16F1826 cannot get MCLR to act as an INPUT

    Here is my initialization code for 16F1826 . I want RA5 to act as an INPUT. However, when I check PortA.5 no matter if it is HI or LO, it does not seem to function as an INPUT.
    I have a 100k ohm resistor to +5VDC from pin4. I simply short the pin to GND to simulate the port as LO.

    Code:
    #CONFIG
     __config _CONFIG1, _FOSC_HS & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
     __config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _STVREN_OFF
    #ENDCONFIG
    
    '_MCLRE_OFF = MCLR pin functions as INPUT RA5, MCLR internally tied to VDD
    
    DEFINE OSC 4
    DEFINE ADC_BITS 10       ' 10 bit A/D Conversion
    DEFINE ADC_CLOCK 4       ' 4MHz Clock
    DEFINE ADC_SAMPLEUS 50   ' 50 uS A/D sample time
    
    TRISA = %00101100       ' Set RA2, RA3 and RA5 as Inputs
    TRISB = %00000000       ' All PortB as Output
    
    'ADC Setup
    ADCON1 =%11000000       ' Right justified
    ANSELA =%00000010       ' AN2 on PortA.2 Analog
    ANSELB =%00000000       ' Digital inputs
    
    adval var word
    
    mainloop:
    if PortA.5= 1 then PortB.1 = 1 'turn ON an LED
    if PortA.5= 0 then PortB.1= 0 'turn OFF an LED
    goto mainloop
    I do not get it. Help! Thanks!
    Last edited by SOTASOTA; - 10th February 2014 at 20:03.

Similar Threads

  1. ICSP with MCLR as input
    By Luckyborg in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th June 2013, 16:40
  2. Q: using MCLR for Input on 12F683
    By picster in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 31st January 2009, 15:25
  3. MCLR line input only
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th April 2008, 23:14
  4. Mclr As Input Pin?
    By omid_juve in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th December 2007, 06:33
  5. RA5/MCLR input in 16f88
    By kacho in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 5th April 2005, 17:21

Members who have read this thread : 1

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