16F628A and RA5 (MCLR pin)


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2005
    Posts
    130

    Default 16F628A and RA5 (MCLR pin)

    Hi, after reading Melanie's excellent tutorial on programming fuses, I started a program that uses every pin of the uC, 14 are used for driving 2x 7 segments display and the other two are used for a couple of buttons.

    My problem is with th RA5 pin, I want it to be an output, but I cant make it work that way, its just off, cant use it, so the connected segment is obviously always off, here is the header im using:

    @ DEVICE pic16F628a, INTRC_OSC_NOCLKOUT
    ' System Clock Options
    @ DEVICE pic16F628a, WDT_ON
    ' Watchdog Timer
    @ DEVICE pic16F628a, PWRT_ON
    ' Power-On Timer
    @ DEVICE pic16F628A, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE pic16F628a, BOD_Off
    ' Brown-Out Detect
    @ DEVICE pic16F628a, LVP_OFF
    ' Low-Voltage Programming
    @ DEVICE pic16F628a, CPD_ON
    ' Data Memory Code Protect
    ' Set to CPD_OFF for Development Copy
    ' Set to CPD_ON for Release Copy
    @ DEVICE pic16F628a, PROTECT_ON
    ' Program Code Protection
    ' Set to PROTECT_OFF for Development Copy
    ' Set to PROTECT_ON for Release Copy

    trisb =%10000000
    trisa =%10000000
    cmcon =%00000111 'Comparators Off
    vrcon =%00000000
    intcon =%00000000

    as you see buttons are on pin 7 of each port.


    What else I need to set to use RA5?


    I sill didnt protoboarded it, im just simulating with preteus vsm, and besides the ra5 segment, program works 100 as expected.


    Thanks in advance

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    948


    Did you find this post helpful? Yes | No

    Default You cannot

    RA5 (MCLR) cannot be used as an output. You may only use it as MCLR or input.

    Jerson

  3. #3
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Ok, so if I swap one of the segments with one of the switchs it should work? say for example ra7 swapped for ra5 and set trisa as:

    trisa=%00100000

    Do I need to change something else?


    Thanks

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    you're right! nothing else to change
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    I just tried the attached circuit with this code:

    @ DEVICE pic16F628a, INTRC_OSC_NOCLKOUT
    @ DEVICE pic16F628a, WDT_ON
    @ DEVICE pic16F628a, PWRT_ON
    @ DEVICE pic16F628A, MCLR_OFF
    @ DEVICE pic16F628a, BOD_Off '(off si es muy baja la alimentacion)
    @ DEVICE pic16F628a, LVP_OFF
    @ DEVICE pic16F628a, CPD_Off
    @ DEVICE pic16F628a, PROTECT_Off


    trisb =%00000000
    trisa =%00100000
    cmcon =%00000111 'Comparators Off

    porta=0
    portb=0
    loop:
    if porta.5=1 then
    porta.4=1
    porta.3=0
    else
    porta.3=1
    porta.4=0

    endif
    goto loop

    and it only lits the led on ra3

    Any idea? Maybe its a simulator issue (proteus vsm)

    Thanks
    Attached Images Attached Images  

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    PORTA.4 is an open drain type. so you can't really drive it like that... you can drive it low but not high... well not directly.

    BTW you really need to a resistor in serie with your LEDs to limit the current.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Thanks Steve, I changed common cathode for common anode display and now it works as expected!!

Members who have read this thread : 0

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