Digital output (RA5) on 16f884


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Default Digital output (RA5) on 16f884

    Help......

    Hi Thank you for reading..... I am attempting to output 16 Leds on ports A and C using a 16F884

    All is working ok but for RA5 (Pin7)..... I suspect I have not turned of an analogue function but what one..

    Any help welcome..... all code is working fine but for this pin.... It just stays high all time !

    See my headers below.

    Thank you for reading

    Andy



    Code:
    '__config _CONFIG1, 
    '_INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF &_CDP_OFF
    
     '__config _CONFIG2, _WRT_OFF & _BOR40V
     
    'Port A Leds
    'Port B Buttons with Internal Pullups
    'Port C Leds
    'Port D Display
    
    ' LCD should be connected as follows:
    '       LCD     PIC
    '       DB4     PortD.0
    '       DB5     PortD.1
    '       DB6     PortD.2
    '       DB7     PortD.3
    '       RS      PortD.4 
    '       E       PortD.5
    '       RW      Ground
    '       Vdd     5 volts
    '       Vss     Ground
    '       Vo      50K potentiometer (or ground)
    '       DB0-3   No connect
        
        OSCCON = $70    'Sets internal Osc at 8Megs
        
        ANSEL=0         'Turn off Analogs
        ANSELH=0     
        ADCON0=0
        ADCON1=0
        CM1CON0=0
        CM2CON0=0
        CM2CON1=0
        CCP1CON=0
        CCP2CON=0
        
        OPTION_REG.7=0  'Port B Pullups active
        
        TRISA=0         'PORT A Outputs
        TRISB=15        'PORT B Inputs
        TRISC=0         'PORT C Outputs
    
        DEFINE LCD_DREG PORTD
        DEFINE LCD_DBIT 0
        DEFINE LCD_RSREG PORTD
        DEFINE LCD_RSBIT 4
        DEFINE LCD_EREG PORTD
        DEFINE LCD_EBIT 5
        DEFINE LCD_BITS 4
        DEFINE LCDLINES 2
         
    
        LED0 VAR PORTA.0
        LED1 VAR PORTA.1
        LED2 VAR PORTA.2
        LED3 VAR PORTA.3
        LED4 VAR PORTA.4
        LED5 VAR PORTA.5
        LED6 VAR PORTA.6
        LED7 VAR PORTA.7
        
        BUT0 VAR PORTB.0
        BUT1 VAR PORTB.1
        BUT2 VAR PORTB.2
        BUT3 VAR PORTB.3
        BUT4 VAR PORTB.4
        BUT5 VAR PORTB.5
        BUT6 VAR PORTB.6
        BUT7 VAR PORTB.7
        
        LED8 VAR PORTC.0
        LED9 VAR PORTC.1
        LED10 VAR PORTC.2
        LED11 VAR PORTC.3
        LED12 VAR PORTC.4
        LED13 VAR PORTC.5
        LED14 VAR PORTC.6
        LED15 VAR PORTC.7

  2. #2
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Digital output (RA5) on 16f884

    Hi All

    Looked at this a little bit further..... I now believe it is RB5/AN13/T1G Causing me the issue.

    Maybe the T1G Timer ??

    How do I disable this and make the port just a DI

    Many thanks

    Andy

  3. #3
    Join Date
    Aug 2011
    Posts
    408


    Did you find this post helpful? Yes | No

    Default Re: Digital output (RA5) on 16f884

    TRISB = 15

    You're only setting RB0-RB3 as inputs

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Digital output (RA5) on 16f884

    Andy, Make sure CM2CON1 is set to all zero's.

    CM2CON1 = %00000000
    This register defaults to T1GSS to T1G enabled at power on. I don't however believe that is the problem.
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Digital output (RA5) on 16f884

    Quote Originally Posted by tumbleweed View Post
    TRISB = 15

    You're only setting RB0-RB3 as inputs
    Thanks both for help..... Missing the obvious, for some reason I copied and pasted previous code, but left TRISB as 15.

    Changed to 255 and all works now......

    Thank you again

  6. #6
    Join Date
    Jan 2006
    Location
    Slovenia EU
    Posts
    32


    Did you find this post helpful? Yes | No

    Default Re: Digital output (RA5) on 16f884

    You have porta set to output try with resistor 4K7 between RA5 and VCC.

  7. #7
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,588


    Did you find this post helpful? Yes | No

    Default Re: Digital output (RA5) on 16f884

    Just a tip for visual people like me:

    - use individual bits for fuses, it's much easier to determine which bit is ON or OFF.

    For example:
    TRISB=%00001111
    versus
    TRISB=$0F
    versus
    TRISB=15

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  8. #8
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: Digital output (RA5) on 16f884

    Quote Originally Posted by Demon View Post
    Just a tip for visual people like me:

    - use individual bits for fuses, it's much easier to determine which bit is ON or OFF.

    For example:
    TRISB=%00001111
    versus
    TRISB=$0F
    versus
    TRISB=15

    Robert
    Very good advice.... My problem is disciplining myself to carry it out.

    Maybe I need slow down a bit :-)

    BR
    Andy

Similar Threads

  1. Fuses issue on 16f884.... Locked out ??
    By andybarrett1 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 18th May 2017, 15:50
  2. Port Digital Output Not Changing Properly
    By rsocor01 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th March 2017, 08:06
  3. PIC16F685 RA4/RA5 pins
    By Adrian in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 9th November 2008, 16:45
  4. open drain output as digital output?
    By droptail in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th November 2006, 04:11
  5. Rx433 linear and digital output
    By mbw123 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th October 2006, 22:26

Members who have read this thread : 1

You do not have permission to view the list of names.

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