trouble with my 16f84a


Closed Thread
Results 1 to 27 of 27
  1. #1
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12

    Default trouble with my 16f84a

    Hello, I've gotten to dabbling with some old pics that I've had stashed away this holiday, and I am experiencing something strange with one of the ports.I'll
    try to make the scenario as clear as possible.

    I'm going through the old "Pic Robotics" book by John Iovine. I haven't tinkered with PIC stuff in a year or two so I figured it would be a good idea to test them with the simple "wink" program using 2 LEDS. I won't post the actual tech drawing here as I'm sure most of you are familiar with it. In any case, only one LED is blinking(rb0).The other(rb1) isn't doing anything.

    I've read the PICs and went over the circuit several times and still can't figure out whats going on.I've also programmed two different pics, but I get the same result each time.I'm using the EPIC Plus if that helps at all. Does anyone have any idea what I could be doing wrong?

    Here's the code in case someone sees something I'm missing.Thanks for looking!

    Shawn

    start:
    high portb.0
    low portb.1
    pause 500
    low portb.0
    high portb.1
    pause 500
    goto start

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Have you tried a different pin another LED?
    I do not see anything wrong with the part of your code you have posted.
    How do you have TRISB set?
    If you post the whole code it would help.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Question

    Hi,

    What about your oscillator settings ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Have you tried a different pin another LED?
    I do not see anything wrong with the part of your code you have posted.
    How do you have TRISB set?
    If you post the whole code it would help.


    That's actually the entirety of the code(although I set TRISB to 0 anyway).Not much to it.Also the oscillator setting is set for crystal.(xt).I tried it with a different pin and came up with the same problem.When I took the LED away from pin 6(rb0) however, the other lit up.

    I'm wondering if it may be a power supply problem.I've currently got a 7805 voltage regulator to step down a 9 volt battery, but I'm wondering if the battery is too low.

    The battery rates at 7.97 volts according to my meter.Could this be too low after the 7805 is connected?

    Shawn

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    PicBasic will defualt to 4MHz. So if your crystal is running at 4 then you should be OK.
    I think it is a good idea to leave nothing to chance and define it at all times.
    Code:
    DEFINE OSC 8 'Speed of OSC
    I also think it is better to set each bit of TRIS?.
    0 = Outpuit
    1 = Input
    Code:
    TRISB = $00000000
    While you are brushing up on things, these two threads are a must read.
    Even if you do not set the fuses in code space this will give you a better understanding of how it all works.
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    The chip you are using has analog.
    http://www.picbasic.co.uk/forum/showthread.php?t=561

    Power supply.
    9 volt battery is to wimpy. Better off to use a pack of AA if you want to run off batteries.
    Check the data sheet of the 7805 to find minimum voltage. At least 2 volt higher than out put.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    I looked at the melabs datasheet and it says that I do not have analog pins. I'm not go to dismiss the possibility that I misunderstood though
    I also looked at the info on the configuration fuses, and while it's pretty cool to be able have access to those, I'm positive I would just be digging my self a larger and more frustrating hole.
    Any other ideas what could be the problem? I'm stumped.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cavity creep View Post
    I looked at the melabs datasheet and it says that I do not have analog pins. I'm not go to dismiss the possibility that I misunderstood though
    My mistake, dirty glasses

    I would say try a better power supply. Is there a way to pull power from the EPIC?
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Not that I know of.At least I don't think so. I tried another power supply(some aa's) , but to no avail. I'm wondering if the programmer is not setting the pin high as intstructed. Could this be a problem with the EPIC or perhaps a bad cable? Is there any way to test the programmer(or the chips for that matter) for a defect?
    If anyone needs me, I'll be staring blankly at this breadboard with with contempt.
    Thanks,
    Shawn

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Unhappy

    Hi, Shawn

    Did you also think to tie the MCLR pin to V+ ???

    some details about Hardware are not too much nor ... YOUR scheme will be perfect.

    ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Hi Alain. Yes it's definitely tied to positive.I'm actually getting power throughout the chip, only little or no power to the portb pins for some reason.
    I was wondering if this was an intermittent kind of problem initially, because I would get at least one LED to blink and then none at all.But two different PICs with the same problem? Also different power supplies seem to be ineffective.

    As far as the circuit goes, I can't find a diagram right now to post(about to head out for the afternoon), but I'll try to give you a breakdown.

    pin 4= POSITIVE with 47k resistor

    pin 5= NEGATIVE

    PIN 6 AND 7= LEDs with 470 ohm resistors(and yes, the polarity is correct)

    pin 14 =positive

    pin 15 and 16 =crystal with two 22 pf caps attached to ground

    If you see something I've done wrong, please feel free to let me know.Frankly I'm baffled.

  11. #11
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Does this work?
    Code:
    P_Val VAR BYTE
    TRISB=0
    
    start:
      P_VAL=2  ' RB0=0, RB1=1
      portb = P_VAL
      pause 500
      P_VAL=1 ' RB0=1, RB1=0
      portb = P_VAL
      pause 500
      goto start
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  12. #12
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    pin 4= POSITIVE with 47k resistor

    pin 5= NEGATIVE

    PIN 6 AND 7= LEDs with 470 ohm resistors(and yes, the polarity is correct)

    pin 14 =positive

    pin 15 and 16 =crystal with two 22 pf caps attached to ground
    I have never seen a 47K resistor on reset pin! Tray a 10K

    Pin 5 negative? , surely you mean ground !

    crystal with two 22 pf caps attached to ground (4 MHz?)

    In your program modify pause to 5000, then with a DVM measure port pins. If you see both pins turning on & off then you have a bad ground or a bad resistor or a bad led connected to the led that doesn't work. On the other hand if you don't see the +5 volts ont both pins than you have a bad pic.

    Appart from that I don't see reason for your leds not blinking.

    Al.
    Last edited by aratti; - 30th November 2008 at 06:28.
    All progress began with an idea

  13. #13
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi, Shawn

    Could you post your HEX code ( not Basic ! ) ???

    I think it's the only way to verify what you put into your Pic ... ( Mr de la Pallice dixit )

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  14. #14
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    I have never seen a 47K resistor on reset pin! Tray a 10K

    Pin 5 negative? , surely you mean ground !

    crystal with two 22 pf caps attached to ground (4 MHz?)

    In your program modify pause to 5000, then with a DVM measure port pins. If you see both pins turning on & off then you have a bad ground or a bad resistor or a bad led connected to the led that doesn't work. On the other hand if you don't see the +5 volts ont both pins than you have a bad pic.

    Appart from that I don't see reason for your leds not blinking.

    Al.

    For this particular PIC at least , it seems to be the norm to use a 47k resistor. The crystal is 4 mhz. And yes,I meant ground:P
    I tried what you recommended , and checked the pins.I am getting a very tiny voltage value ( the last was 35.6 mV.).I've got a feeling I have a couple of bad chips, unless someone can think of another reason for this

    Alain I'm going to post the Hex listing here of the most recent wink program.Thanks for taking a look at it.

    :1000000028288F018E00FF308E07031C8F07031CEA
    :10001000232803308D00DF300F2003288D01E83EB8
    :100020008C008D09FC30031C18288C070318152838
    :100030008C0764008D0F15280C181E288C1C222894
    :1000400000002228080083130313831264000800B1
    :1000500006148316061083128610831686108312E8
    :1000600013308F008830022006108316061083128A
    :10007000861483168610831213308F008830022076
    :060080002828630041285E
    :02400E00FD3F74
    :00000001FF

  15. #15
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cavity creep View Post
    For this particular PIC at least , it seems to be the norm to use a 47k resistor.
    ???
    Do you mean 4.7K
    Dave
    Always wear safety glasses while programming.

  16. #16
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Yes I did.Apologies for the typos.

  17. #17
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cavity creep View Post
    Yes I did.Apologies for the typos.
    Darn, that probably would have been the problem.

    I do not have an 84A to test your HEX with, but I can say the fuses are correct.
    I do not think it will make a difference, but you may try setting the WatchDogTimer to OFF??
    Dave
    Always wear safety glasses while programming.

  18. #18
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Would you believe that did the trick?????

    Thanks you so much! Can you give a little insight into what exactly is going on with the timers?I'm certain I'll run into this again.

    Thanks again to everybody for their insight

    Shawn

  19. #19
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    The data sheet says it best. If not, let us know.
    6.10 Watchdog Timer (WDT)
    The Watchdog Timer is a free running On-Chip RC
    Oscillator which does not require any external
    components. This RC oscillator is separate from the
    RC oscillator of the OSC1/CLKIN pin. That means that
    the WDT will run even if the clock on the OSC1/CLKIN
    and OSC2/CLKOUT pins of the device has been
    stopped, for example, by execution of a SLEEP
    instruction. During normal operation, a WDT time-out
    generates a device RESET. If the device is in SLEEP
    mode, a WDT wake-up causes the device to wake-up
    and continue with normal operation. The WDT can be
    permanently disabled by programming configuration bit
    WDTE as a '0' (Section 6.1).
    6.10.1 WDT PERIOD
    The WDT has a nominal time-out period of 18 ms, (with
    no prescaler). The time-out periods vary with
    temperature, VDD and process variations from part to
    part (see DC specs). If longer time-out periods are
    desired, a prescaler with a division ratio of up to 1:128
    can be assigned to the WDT under software control by
    writing to the OPTION_REG register. Thus, time-out
    periods up to 2.3 seconds can be realized.
    The CLRWDT and SLEEP instructions clear the WDT
    and the postscaler (if assigned to the WDT) and prevent
    it from timing out and generating a device
    RESETcondition.
    The TO bit in the STATUS register will be cleared upon
    a WDT time-out.
    Dave
    Always wear safety glasses while programming.

  20. #20
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Well here's the strange thing.Shutting off the watchdog timer works quite well on one PIC.It functions as it is supposed to.However, I tried the exact same thing in the exact same circuit with the other pic, and it doesn't work. Same old problem. Also the book I've been referencing states to set the watchdog and power up timers on.
    Any thoughts?

  21. #21
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cavity creep View Post
    Well here's the strange thing.Shutting off the watchdog timer works quite well on one PIC.It functions as it is supposed to.However, I tried the exact same thing in the exact same circuit with the other pic, and it doesn't work. Same old problem. Also the book I've been referencing states to set the watchdog and power up timers on.
    Any thoughts?
    Just guessing...as usual.

    Try reading the PIC and see if that hex matches the hex generated by the assembler. The config part might not be getting programed correctly.

    If they are not the same.

    Erase all but the chips ID if the EPIC has that setting. Then write to the chip program memory and config settings.
    Dave
    Always wear safety glasses while programming.

  22. #22
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Nope.They look the same.

  23. #23
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Exclamation

    Hi,

    Works fine, as written ...

    Hardware problem ( or config ) ... then !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  24. #24
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Have you tried the code example I posted above?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  25. #25
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    Works fine, as written ...

    Hardware problem ( or config ) ... then !!!

    Alain
    I'm going to have to agree with you I think.I suppose I have one good PIC and one bad, but I would think I would have difficulty reading from the ports of aa bad one, or at the very least the programmer would fail to recognize it.Maybe I'm asking for too much.

    Bruce, I haven't tried your code yet.I'm afraid your suggestion got buried in the conversation.I think I'll give it a try and post the results later if I have any success.

    Thanks for everyone for helping me figure this out.I'm sure I'll have many more questions as I go

  26. #26
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Lightbulb Idea

    Hi,

    I'd suggest you to try to place 4.7k and 22 pf as the external RC Clock components ... and give a try like that ...

    no risk !

    Will tell if CONFIG Word is transmitted by the programmer ...

    Just one step further.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  27. #27
    Join Date
    Nov 2008
    Location
    Columbus, OH, USA
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    I'd suggest you to try to place 4.7k and 22 pf as the external RC Clock components ... and give a try like that ...

    no risk !

    Will tell if CONFIG Word is transmitted by the programmer ...

    Just one step further.

    Alain
    Do you mean to use a 4.7 k resistor instead of the crystal and set the oscillator at RC?

Similar Threads

  1. Code works on 16F84A but not on 16F88?
    By pharaohamps in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th November 2009, 18:29
  2. MCLR causing trouble . .
    By shahidali55 in forum General
    Replies: 10
    Last Post: - 21st December 2007, 12:20
  3. ICSP using a 16F84a to program 24CXX
    By aftab in forum mel PIC BASIC
    Replies: 26
    Last Post: - 8th April 2007, 11:39
  4. 16F84A and Optrex LCD
    By coyotegd in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th October 2005, 16:08
  5. RS 485 using 16F84A
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th May 2005, 14:46

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