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

Thread: Flashing an LED problem...

  1. #1
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default Flashing an LED problem...

    Hi folks. I'm using Pommie's program to flash an LED, first time it worked, and I have one chip that flashes, but the same programs on the next two chips hangs after a couple or three minutes, and the LED stops flashing. The same program I used is this one modified slightly for time. Does anyone know why it stops flashing after three minutes?

    LIST p=16F88
    include "P16F88.inc"
    __config _CONFIG1, _WDT_OFF & _INTRC_IO & _MCLR_ON

    cblock 0x20
    ;variables go here
    d1
    d2
    d3
    endc

    org 0x0000 ;start of program
    init
    bsf STATUS,RP0 ;bank 1
    movlw 0x42 ;8MHz internal osc
    movwf OSCCON
    movlw 0x07 ;turn comparators off
    movwf CMCON
    clrf ANSEL ;all pins digital
    movlw 0x00 ;all pins outputs
    movwf TRISA ;& 0x7f
    movwf TRISB
    bcf STATUS,RP0 ;select bank 0

    main bsf PORTA,1
    call delay
    bcf PORTA,1
    call delay
    goto main

    delay movlw 0x15
    movwf d1
    movlw 0x74
    movwf d2
    movlw 0x01
    movwf d3
    delay_0 decfsz d1,f
    goto dd2
    decfsz d2,f
    dd2 goto dd3
    decfsz d3,f
    dd3 goto delay_0
    return

    end
    Last edited by RobertD; 29th June 2008 at 01:54 PM.


  2. #2
    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,711
    Blog Entries
    5

    Default

    Looks fine, nothing looks like it would overflow the stack or stop after 3 minutes.
    movlw 0x42 ; is 1MHz (0x72 = 8)

    PS use the code "#" button tags instead of quotes as it retains the formatting.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  3. #3
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    The debugger runs through no problem. I just don't know why it stops flashing...?

    I tried different delays, same thing happens.
    And yes I didn't change the 1mhz time when I adjusted the clock.
    Last edited by RobertD; 29th June 2008 at 02:19 PM.

  4. #4
    Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent
    Join Date
    Jan 2005
    Location
    Michigan, USA
    Posts
    2,522

    Default

    Hi Robert,

    Add _LVP_OFF to your configuration line...

    Have fun.

    Mike
    Last edited by Mike, K8LH; 29th June 2008 at 02:28 PM.

  5. #5
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    I found it... I was running the LED directly from the chip, and it was running hot. I put a current limiting resistor and changed the LED now it's running OK...

    Baby steps can be frustrating sometimes...

    _LVP_OFF, what will this do?

    No... it stopped again...

    I'll add _LVP_OFF see if that works.
    Last edited by RobertD; 29th June 2008 at 02:58 PM.

  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,711
    Blog Entries
    5

    Default



    Use your Firefly, it has the limiting resistors.

    You can blink a Firefly LED easy
    change your PORTA,1 to PORTA,6 in the main loop.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  7. #7
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    Baby steps are frustrating...

    but necessary.

    LED is on again.

  8. #8
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    Quote Originally Posted by blueroomelectronics View Post


    Use your Firefly, it has the limiting resistors.

    You can blink a Firefly LED easy
    change your PORTA,1 to PORTA,6 in the main loop.
    OK will do that. I do have to get into the firefly for the AD programming.

    Like this you mean:

    main
    bsf PORTA,6
    call delay
    bcf PORTA,6
    call delay
    goto main
    Last edited by RobertD; 29th June 2008 at 03:21 PM.

  9. #9
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    Fantastic, I have LED 1 and 2 flashing....

    I programmed in the ZIF socket and transferred the chip to the tutor position.

    Actually 1 flashes red, and 2 flashes green.
    Last edited by RobertD; 29th June 2008 at 03:25 PM.

  10. #10
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    Now I have to program RB4 (switch 3) to trigger the AD read when pressed. So I can read the output on ADRESH/L, in MPLAB.

    The firefly has all the features I need for my program, LED's, A/D inputs, and switches...

    First step, make PORTB,4 input.
    Last edited by RobertD; 29th June 2008 at 03:52 PM.

  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,711
    Blog Entries
    5

    Default

    You don't have to move it from the ZIF to the Tutor socket, just turn the tutor dip switch on and the 40,18 switches off.
    Bill
    Smart Kits build Smart People

    http://www.blueroomelectronics.com/

  12. #12
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    I program the chip while it's running? I thought I had to stop the program before programming it. That'swhy I took it out of tutor and put it in the ZIF

    I programmed this to get the flashing LEDs to stop when pressing the switch RB0, but it's not working. I use weak pull-up to turn all PortB switches on, when I press RB0, I ground it, at least that's what I'm thinking, unless the switch RB0 is not connected to ground.


    movlw B'11111111' ;make all Bports input
    movwf TRISB
    BCF OPTION_REG,7
    bcf STATUS,RP0 ;select bank 0

    main
    bsf PORTA,6
    call delay
    bcf PORTA,6
    call delay
    btfsc PORTB,0
    goto main
    goto skip

    (delay routine here)

    skip nop
    end
    Last edited by RobertD; 29th June 2008 at 06:06 PM.

  13. #13
    Boomslang Good Boomslang Good
    Join Date
    Mar 2007
    Location
    South Africa
    Posts
    253

    Default

    I have not used that hardware, so can't comment on the RB0 to ground (did you try btfss). Just one thing I usually do, instead of letting the program run to end, rather put in something like:
    GOTO $-0 which will put it in an infinite loop at that position, and you can put the rest of your delay and other routines under that line.

    How long are your delays, are you keeping the switch pressed in long enough?
    Last edited by Boomslang; 29th June 2008 at 06:17 PM.

  14. #14
    RobertD Good RobertD Good
    Join Date
    May 2008
    Location
    Brampton Ontario
    Posts
    216

    Default

    Hi Boomslang, I tried btfss, that didn't work either, I use a one second delay, and I press the switch long enough, I just have to keep pecking at it until it works... I should read the user manuel and get to know how the firefly is built, it really is a handy programmer.

  15. #15
    Boomslang Good Boomslang Good
    Join Date
    Mar 2007
    Location
    South Africa
    Posts
    253

    Default

    Have a look at the circuit diagram to see how the pin is setup.

    A way to make your code a bit smaller:

    Code:
    main
          btg     PORTA,6
          call     delay
          btfsc   PORTB,0
          goto    main
          goto $-0
    
    (delay routine here)
    
    Last edited by Boomslang; 29th June 2008 at 08:15 PM.

+ Reply to Thread
Page 1 of 2
1 2 Last

Similar Threads

  1. Flashing a LED with Mouse
    By Gayan Soyza in forum Electronic Projects
    Replies: 20
    Latest: 6th February 2009, 02:24 AM
  2. Flashing Dog Collars
    By TheTiffy in forum Electronic Projects Design/Ideas/Reviews
    Replies: 7
    Latest: 4th April 2008, 01:40 AM
  3. flashing LED,s
    By mick the builder in forum Electronic Projects Design/Ideas/Reviews
    Replies: 7
    Latest: 15th December 2006, 08:18 PM
  4. low current flashing LED
    By joecool85 in forum Electronic Projects Design/Ideas/Reviews
    Replies: 51
    Latest: 21st March 2006, 01:44 PM
  5. flashing LED
    By 1997 GA16DE in forum General Electronics Chat
    Replies: 11
    Latest: 29th February 2004, 05:52 PM

Tags for this Thread