+ Reply to Thread
Page 1 of 2
1 2 Last
Results 1 to 15 of 17

Thread: PIC16F628A not stable ?

  1. #1
    Hero.sl Newbie
    Join Date
    Nov 2008
    Location
    Colombo
    Posts
    34

    Angry PIC16F628A not stable ?

    Hi all
    Im just trying to test whether my PIC is correctly programmed, using the following SIMPLE circuit.


    (LED blinker) But the problem is the output is unstable. It only works when I touch the VDD pin. Any ideas?
    Im using WinPic programmer, No errors in programming the PIC.
    WDT is off. using Internal oscillator @ 4MHz.
    Thanks


  2. #2
    kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent kchriste Excellent
    Join Date
    Jul 2006
    Location
    Victoria BC, Canada
    Posts
    3,681

    Default

    Sounds like you need a 0.1uF capacitor across pins 5 & 14 of the PIC.
    You should also have a 10K resistor between pins 4 & 14 if MCLR is enabled in software.
    Inside every little problem, is a big problem trying to get out.

  3. #3
    3v0
    3v0 is offline
    3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent 3v0 Excellent
    Join Date
    Jul 2006
    Location
    USA
    Posts
    6,464
    Blog Entries
    11

    Default

    It looks like you missed the reset pullup resistor on MCLR and there is no bypass cap between Vdd and Vss.
    3v0

    Quote Originally Posted by Hero.sl View Post
    Hi all
    Im just trying to test whether my PIC is correctly programmed, using the following SIMPLE circuit.


    (LED blinker) But the problem is the output is unstable. It only works when I touch the VDD pin. Any ideas?
    Im using WinPic programmer, No errors in programming the PIC.
    WDT is off. using Internal oscillator @ 4MHz.
    Thanks
    Last edited by 3v0; 17th November 2008 at 03:42 AM.
    Please post questions to the forums. PM's are for personal communication.

    BCHS/3v0's Tutorials
    Junebug USB PIC programmer kit., USB Bit Whacker,
    The 15 Minute Printed Circuit Board! (+drill time)

  4. #4
    Gayan Soyza Excellent Gayan Soyza Excellent Gayan Soyza Excellent Gayan Soyza Excellent Gayan Soyza Excellent Gayan Soyza Excellent
    Join Date
    Oct 2006
    Location
    Colombo
    Posts
    1,664
    Blog Entries
    1

    Default

    Yes Hero.sl should turn OFF MCLR in the fuse settings.

  5. #5
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,804

    Default

    Don't turn off MCLR in your code or you may not be able to reprogram it. Use a pullup resistor instead.

    Mike.

  6. #6
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,705
    Blog Entries
    5

    Default

    Here's a small LED blink program & schematic for a 16F628A
    Find the PDF by on this page. blueroomelectronics Downloads
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  7. #7
    Hero.sl Newbie
    Join Date
    Nov 2008
    Location
    Colombo
    Posts
    34

    Smile

    Thanks guyz.. now its working.
    I thought we should pull up MCLR only when programming.

    I noticed that when I remove the 470Ω resistor, the LED is always on instead of blinking(Blueroom's circuit). How does the voltage on RB0 affect the process?
    Last edited by Hero.sl; 17th November 2008 at 04:12 AM.

  8. #8
    futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent futz Excellent
    Join Date
    Sep 2007
    Location
    Vancouver, B.C.
    Posts
    1,980

    Default

    Quote Originally Posted by Hero.sl View Post
    I thought we should pull up MCLR only when programming.
    Exactly the opposite. When the programmer is plugged in to the ICSP connector, it controls the MCLR pin.

    But when you disconnect the programmer your MCLR pin is floating, so the chip is likely to be in reset at least 50% of the time. If MCLR is enabled you MUST have a (typically 10K to 33K) pullup resistor to hold the pin high.
    =========================
    Futz's Microcontrollers & Robotics
    =========================

  9. #9
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,705
    Blog Entries
    5

    Default

    My circuit the 470 ohm resistor across the LED, you need it to limit current.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  10. #10
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,804

    Default

    If you remove the 470Ω resistor then the load on the pin becomes too much and the pin never gets to a voltage that would be read back as a logic low. It will always be around 3V.

    If you change the code to,
    Code:
    		list	p=16F628A
    		include	<p16F628A.inc> 
    		__config 0x3F34
    		org	0
    		bsf	STATUS, RP0
    		movlw	b'00001110'
    		movwf	OPTION_REG
    		bcf	TRISB, 0
    		bcf	STATUS, RP0
    		movlw	1
    		xorwf	0x20,F
    		movfw	0x20
    		movwf	PORTB, f
    		sleep
    		end
    
    it should start flashing again. This works because it uses a SFR (ram) location to remember the previous state.

    Mike.
    Last edited by Pommie; 17th November 2008 at 04:17 AM. Reason: typo

  11. #11
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,705
    Blog Entries
    5

    Default

    Ahh the RMW rears it's ugly head.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  12. #12
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,804

    Default

    Quote Originally Posted by blueroomelectronics View Post
    Ahh the RMW rears it's ugly head.
    Yes, but no amount of delay will fix the problem as it's caused by overloading the pin.

    Mike.

  13. #13
    Help us help you blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent blueroomelectronics Excellent
    Join Date
    Jan 2007
    Location
    Toronto, Canada
    Posts
    10,705
    Blog Entries
    5

    Default

    You're right, I try to be careful not to overload the pins. I wonder if the 18F LAT (and new 14bit core LAT) will have the same issue?
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  14. #14
    Hero.sl Newbie
    Join Date
    Nov 2008
    Location
    Colombo
    Posts
    34

    Default

    I got it. but another question. Even after declaring PortB as outputs, does it read the pins and change PORTB?
    What will happen to PORTB when the WTD timeouts?

  15. #15
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,804

    Default

    When a pin is set to output and you read it's value, you will get the value on the pin which maybe different to what was previously written if the pin is overloaded.

    When the WDT times out it resets the pic and the pin gets toggled by the xor instruction. When you removed the resistor you overloaded the pin and it always read back as a logic one. The xor instruction changed the 1 to a zero and wrote it back therefore always lighting the LED.

    Mike.

+ Reply to Thread
Page 1 of 2
1 2 Last

Similar Threads

  1. bi-stable latching relay?
    By wsemajb in forum General Electronics Chat
    Replies: 10
    Latest: 3rd June 2008, 11:32 PM
  2. Clueless A-stable multivibrator ?????????
    By JAMES IRVINE in forum Electronic Projects Design/Ideas/Reviews
    Replies: 8
    Latest: 18th April 2008, 12:27 PM
  3. stable dc-dc converter
    By fever in forum Electronic Projects Design/Ideas/Reviews
    Replies: 19
    Latest: 12th May 2007, 07:26 PM
  4. making a pc psu more stable
    By Thunderchild in forum General Electronics Chat
    Replies: 8
    Latest: 10th February 2007, 01:03 PM
  5. Mono stable 555 circuit
    By b1mmuo27 in forum Electronic Projects Design/Ideas/Reviews
    Replies: 9
    Latest: 28th June 2006, 03:01 PM

Tags for this Thread