16F627 porta problems


Closed Thread
Results 1 to 10 of 10
  1. #1
    electronicsuk's Avatar
    electronicsuk Guest

    Question 16F627 porta problems

    Sorry to post so soon after my last thread, however I have stumbled across a problem with the porta pins on my 16F627 microcontrollers.

    Say I program this into the microcontroller for testing:
    loop:
    HIGH porta.0
    PAUSE 500
    HIGH porta.1
    PAUSE 500
    HIGH porta.2
    PAUSE 500
    GOTO loop

    The ports should then turn on one by one and stay on until the microcontroller is reset. However, they don't. Porta.0 will come on for 1/2 a second, go off, then a.1 will come on for 1/2 a second, turn off, and so on. So I am getting an output, but it's not correct.

    I know that 16F628 ports default to analogue and I thought the case might be similar with the 627, so I added CMCON=7 at the start of the code. No luck with that either.

    Can anyone shed some light on this problem?

    Matthew

  2. #2
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Question

    That surely does not look right.

    Are you trying to source too much current through the pins? What are you sourcing, open ckt, led? If you are sourcing something (other than open ckt) do you have enough protection (resistor) for each output?

    I am afraid I can offer no real help except the questions I presented.

    languer.

  3. #3
    electronicsuk's Avatar
    electronicsuk Guest


    Did you find this post helpful? Yes | No

    Default

    I'm running a single LED off the port through a 330 Ohm resistor. That works out to be 16mA not accounting for voltage drop across the LED, so probably closer to 10mA.

    Matthew

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Matthew

    Have you remembered your TRISA statement?

    Otherwise you have a dud PIC - or some other kind of hardware miswire... Your code will work correctly as expected... I have quickly tried it myself since I've a breadboard in front of me... the appended code works as expected... compile it and try for yourself...

    Melanie
    Attached Files Attached Files

  5. #5
    electronicsuk's Avatar
    electronicsuk Guest


    Did you find this post helpful? Yes | No

    Default

    I assumed that the HIGH and LOW statements automatically set the used ports to outputs, so I will give that a try. I can't see that it would be a wiring problem, the breadboard simply has the PIC,s 4 LED's and resistors.

    I did think at first that PIC might be dud, but this has happened to 3 of them! Anyway, will try your code and see what happens.

    Matthew

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Assume nothing... trust nothing...

    Wasn't that one of Mulder's (X-Files) favourite sayings... anyway since PICs are little alien critters that come from planet Microchip it seems a good phrase to apply...

    Melanie

  7. #7
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Question

    Hi Matthew,

    Are you really, really, REALLY sure you're not sourcing too much current? I'm only asking because your problem sounds exactly what would happen if you forgot(or shorted) the limiting resistor.
    I've forgotten to cut strips on a breadboard more than once. Try measuring the voltage on the pins, if it's not close to 5(or 0) volts you're in trouble. Between 1 and 4 is "out of bounds".

    /Ingvar

  8. #8
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Default

    Duuuhhh, just realized that a "breadborad" is one of those plastic boards full of holes, not the predrilled PCB i had in mind.

    /Ingvar

  9. #9
    electronicsuk's Avatar
    electronicsuk Guest


    Did you find this post helpful? Yes | No

    Default

    I'm practically certain about the current draw. I have not yet had the time to try out the suggested ideas as I have been very busy, but will try and make time this weekend. Another thing I will check (again!) is the regulator, just in case.

    Matthew

  10. #10
    electronicsuk's Avatar
    electronicsuk Guest


    Did you find this post helpful? Yes | No

    Default

    Just to let everyone know that everything now seems to be working fine. I changed the 330 Ohm resistors to 1k and everything worked fine. I then switched back to 330 and again everything continued to work fine, so the problem remains a mystery. Before the problem finally disappeared I had rebuilt the circuit 3 times, so that practically puts a wiring error out of the question, especially with the simplicity of the circuit.

    Many thanks to everyone who helped out.

    Matthew

Similar Threads

  1. Replies: 5
    Last Post: - 16th October 2009, 18:29
  2. PortA 16F627
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th May 2008, 16:12
  3. Changing from PORTC to PORTA Problems
    By Tissy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 13th December 2005, 21:11
  4. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29
  5. PORTA problems 18LF252
    By iphillips in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th February 2005, 13:56

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