PIC16F628 Port B.4 Problem


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Question PIC16F628 Port B.4 Problem

    Hi-

    I cannot find what I am missing. I cannot control Port B.4, it acts as an input and interrupts the program flow. I have code below that shows the problem:

    ' Device Settings
    @ DEVICE PIC16F628 ' PIC Device
    @ DEVICE EC_OSC ' External Oscillator
    @ DEVICE LVP_OFF ' Low-Voltage Programming
    @ DEVICE WDT_OFF ' Watchdog Timer
    @ DEVICE PWRT_ON ' Power-On Reset
    @ DEVICE MCLR_OFF ' Master Clear
    @ DEVICE BOD_OFF ' Brown-Out Detect
    @ DEVICE CPD_OFF ' Data Memory Code Protection
    @ DEVICE PROTECT_OFF ' Program Code Protection

    ' Set Environment Variables
    DEFINE OSC 20 ' Oscillator speed, 20MHz
    TRISA = %00000000 ' Port A All Outputs
    TRISB = %00000000 ' Port B All Outputs

    ' Main Program
    PortB = $FF ' Port B All Set High
    PortB.4 = 1 ' B4 Set High

    While (1)
    toggle PortA.0 ' Heartbeat
    pause 250
    WEND

    END


    When I run this, all port B goes high except B.4. I have tried to use a pull-up, in case it is open collector, but that stops the heartbeat. I have tried several different 628s, and they all act the same. I figure it must be a fuse set wrong, but I don't know what.

    Any help would be gratefully accepted!

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PIC16F628 Port B.4 Problem

    Although your configuration shows LVP_OFF, it's possible that the configuration is not getting programmed into the chip.
    With LVP enabled, if B4 (PGM) goes high it puts the chip in programming mode.

    What programmer are you using?
    And is it set to program the configuration bits?
    DT

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: PIC16F628 Port B.4 Problem

    Is it Port B.4 that you want to toggle? Port A has analog features, you have to disable them first.

    As it is, you set it high and leave it.

    By the way, you don't have to set B.4 high after setting all of Port B high, it's already high.

    Robert

    EDIT: Aren't we supposed to use XT for 20mhz external oscillators? Can't remember, sure I read something about that tonight.
    Last edited by Demon; - 1st May 2012 at 02:42.
    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!

  4. #4
    Join Date
    Apr 2012
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: PIC16F628 Port B.4 Problem

    Hi again-

    I'm using the melabs Serial Programmer (2003) which has served me for many years. I agree that it looks like the LVP fuse is being ignored. Is there a way to check its state? Is there an alternative way to set it?

    As to the program itself, yes, setting both port B and B.4 high is redundant, but the output is low. That is the problem in a nutshell. Toggling A.0 shows me whether the program is running (which it does not seem to be doing).

    Thanks again!

  5. #5
    Join Date
    Apr 2012
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: PIC16F628 Port B.4 Problem

    Never mind, I found it. Darryl was right, the programmer is ignoring my fuse settings. Setting them manually takes care of the issue.

    Sorry for the bother. =)

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