Why is my LED not blinking?


Closed Thread
Results 1 to 15 of 15
  1. #1

    Default Why is my LED not blinking?

    I recently bought a u2 programmer and got the melabs programmer software running in microcode studio just fine. I am programming a pic16f84A in circuit. The programming software sees the pic, says it has uploaded the blinking program but no blink. I have checked the circuit a hundred times and it is the same as is reccommended in the picbasic pro manuel. I am using a ceramic resonator instead of a crystal.
    My question is how could this not work and I assume that the program is on the chip if the programmer said it loaded it on. I also tried it with a 12F675 using the internal oscillator (turning off the comparator and ADC) but no go either. I have been doing stamps for years so am no newbie to electronics. Please help.
    Thanks.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Let's have a look

    Hello Gary,
    Did you remember to set the configuration fuses in the code or on the programmer? Can you post your code? Did you remember to tie the MCLR pin high through a resistor?
    JS
    Last edited by Archangel; - 30th December 2006 at 01:39.

  3. #3


    Did you find this post helpful? Yes | No

    Default yep, did all that.

    Yes, the config bits are set to xt, watchdog off, code protect off, ect. I have tried the other oscillator settings and watchdog on, but no luck. And yes the mclr is pulled high thru a 10k. Heres the 16f84A program:


    loop: High PORTB.0 ' Turn on LED connected to PORTB.0
    Pause 1500 ' Delay for .5 seconds

    Low PORTB.0 ' Turn off LED connected to PORTB.0
    Pause 1500 ' Delay for .5 seconds

    Goto loop ' Go back to loop and blink LED forever
    End

    With the 12f675 I set the config bits in the program:

    @ Device PIC12F675,WDT_OFF,PWRT_ON,PROTECT_OFF,MCLR_ON,BOD_ OFF 'sets configuration
    adcon0=0 ' no ADC doesn't seem necessary but may be a good idea
    ansel=0 'no ADC input - IMPORTANT if using ports in digital mode
    cmcon=7 'turns off comparator function -IMPORTANT if using ports in digital mode
    trisio=0 ' all ports set as outputs - essential to minimize sleep current
    vrcon=0 'turns off Vref for min current
    DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device - calibrates the internal oscillator -not related to SLEEP

    @ DEVICE INTRC_OSC_NOCLKOUT

    loop: high GPIO.5 ' Turn on LED connected to PORTB.0
    Pause 1500 ' Delay for .5 seconds

    Low GPIO.5 ' Turn off LED connected to PORTB.0
    Pause 1500 ' Delay for .5 seconds

    Goto loop ' Go back to loop and blink LED forever
    End

    It must be something stupid but I have torn up the circuit and rebuilt half a dozen times. Im pretty good at breadboarding. I threw in some extra caps on the vdd to vss but I am using an expensive benchtop supply so it should be clean.
    Thanks for you consideration,
    Gary

  4. #4
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Just checking

    And you have a resistor (470 ohm) connected to the LED so you dont fry it?

    And you have tested the LED that it is working by connecting it thru a resistor to the powersupply?

    Checked that you have VDD availible at the PIC and that VSS really connects to the power supply?

    What if you connect a resistor and LED across the PIC VDD and VSS lines, then it should turn on when you start your power supply.

    As you said it is probably something stupid, and then this might be something to start with.

    And dont forget to disconnect the incurcuit programmer since that one will hold the PIC in reset.

    /me

  5. #5


    Did you find this post helpful? Yes | No

    Default All that checked too

    The led lights fine if connected to the pic vdd so its all waiting there for the pic to wake up. That's what I mean; it should work yet no life.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gary Goddard View Post
    The led lights fine if connected to the pic vdd so its all waiting there for the pic to wake up. That's what I mean; it should work yet no life.
    Does you programmer have a verify chip function (it should, but I figured I'd ask anyways)? I've got a Warp13 and one thing that's tripped me up in the past is turning off the verify function 'cause I assumed it was programming a chip, then after hours of trying to figure out what's wrong, I find my programmer cable dangling over the edge of the table. It didn't tell me the chip wasn't programmed 'cause it didn't check! Go figure, but it happens...

    Have you tried putting one chip in, program it, pull it out, try a verify, which obviously should fail, then put a seperate chip in (same type of course), try a verify, again, should fail. If they don't, the programmer might not actually be programming...maybe, perhaps? could happen...

    Watch the PGC and PGD pins during programming on a 'scope (assuming you have one)? The PGC should be cycling regularly and PGD quite erratic. Make sure the MCLR gets pulled all the way up to +12v during programming?

    Just a smathering of a few ideas flustered forth from my fingers for ya....

    Do you have a 'scope? Have you 'scoped the resonator pins? Anything? Or just put a meter on the pins to ground, should have about 1.5-ish volts on them with power.

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Blinky

    Hi Gary,
    here is your blinky, this code works as is.
    it's your code with some add ins, after you check what skimask suggested,
    try this and it should work, then remove parts of this code until it stops working and see what you learned. I think it is the trisb setting your code needed. The chip just didn't know whether to input or output.
    JS
    Code:
    @ DEVICE pic16F84, XT_OSC
    
    @ DEVICE pic16F84, WDT_OFF
    ' Watchdog Timer
    
    @ DEVICE PIC16F84, PWRT_ON
    ' Power-On Timer
    
    DEFINE OSC 4
    
    
    TrisB = %00000000    ' Sets all bits portb as outputs
    
    loop:
    High PORTB.0 ' Turn on LED connected to PORTB.0
    Pause 1500 ' Delay for 1.5 seconds
    
    Low PORTB.0 ' Turn off LED connected to PORTB.0
    Pause 1500 ' Delay for 1.5 seconds
    
    Goto loop ' Go back to loop and blink LED forever
    End

  8. #8
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default TRISB or not

    High and low are according to the PBP manual supposed to set the pin automaticly to an output.

    But I guess it is good practise to to it your self

    /me

  9. #9


    Did you find this post helpful? Yes | No

    Default Still a mystery!

    Ok, pgc on oscilloscope peaks at 5V or so in reg intervals, pgd also active, mclr is at 14 volts during programming, programmer verifies, ceramic resonator is resonating. Stuff is going in that black box just nothing out of it. I have also tried changing the chips, port numbers, used a 16F84, 16F88, 12F675. I have even changed the breadboard. What else can I do?

  10. #10
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    - Can you post a schematic or picture of your setup?
    - Your diode is not reversed? (take it out and measure port with DMM while "running")
    EDIT - As Skimask suggested, is your resonator resonating after you program - I think you tell us it does during programming but how about when you try and run your chip - is it resonating?
    Last edited by paul borgmeier; - 30th December 2006 at 19:54.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  11. #11
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Retool

    I have even changed the breadboard. What else can I do?
    Try a different programmer software, and or a different programmer.
    I use ICPROG available on internet free, with a JDM clone programmer I bought off ebay from a seller in Bulgaria, cost 18 bucks and works always.
    http://www.ic-prog.com/index1.htm
    edit:
    you said you have used stamps for years, which programmer did you use on them, is the one you are using now? Are you using a bootloader to load your PIC? And I am just covering the bases here and not trying to offend, you are loading the HEX file and not one of the others, correct? Last thing, verify MCLR pin is at or near 5v+ when operating, do not attach any load to it though. I had once hooked an LED to MCLR so as to observe and verify reset switch operation and PIC would not work.
    Last edited by Archangel; - 31st December 2006 at 01:40. Reason: add

  12. #12


    Did you find this post helpful? Yes | No

    Default It's working!

    So, I finally found out what was wrong. It was not in the circuit, but the software. From what I had understood Microcode Studio would compile the PicBasic pro program to a hex file and pass that to the programmer software. When I looked at the code in the programmer it was just a bunch of 0FFFs. So I then found the compiled hex file and opened that in the programmer and then programed the pic and voila! Blink. Apparently Microcode studio doesn't pass the hex file along as the stamp editor does. Thanks for all your help and happy New Year.

    By the way I used an Athena rs232 to ttl line driver I had laying around to create a debug to the pc using hyperterminal thru my usb port (using a serial to usb converter.) The microcode studio doesn't seem to have a com 4 port on the serial communicator. So all is well.

  13. #13
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Terrific

    Glad you got it working Gary! Funny It seems so obvious to someone experienced with microcode studio that you have to select the file to load, but to a newbie it seems that the file you just compiled should be loaded when you click program. I will remember this post for someone else's sake down the road.
    Last edited by Archangel; - 1st January 2007 at 10:03. Reason: Add

  14. #14
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hello,

    If you just compiled a program in Microcode Studio by pressing the button for Compile and Program or pressed F10 it should have brought up the programmer window. This is what happens when I use the ME Labs USB programmer or the EPIC programmer. The only time it doesn't is when I use the PIC Flash from Mikroelektronica. Then I have to open the programmer program and then select the .hex file to load. That may be because I don't have the path for PicFlash setup properly. But as long as I have used MCS it has always opened the programmer window with the .hex file ready to load.

    BobK

  15. #15
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    I use a JDM programmer and WinPICpr as the software for squirting the HEX to the PIC. Pressing F10 in microcode studio launches the Winpic pro application, but it doesn't load the code automatically. You still have to use the FILE - LOAD option, and then program the PIC

Similar Threads

  1. Simple Blinking LED - WTF!!
    By johnnylynx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st February 2010, 06:19
  2. Blinking an led problem on P16F84
    By aimenbukharie in forum General
    Replies: 1
    Last Post: - 20th March 2009, 05:00
  3. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. simple LED Blinking project
    By koossa in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th December 2004, 01:25

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