Erratic LED blinking


+ Reply to Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default Re: Erratic LED blinking

    Thanks Jerson.

    At the moment it looked OK to have the LCDout inside the regularly called ISR, as it updatetd the LCD often. If the freq is low enough 1-2 Hz, it updates every second the LCD because of the Pause commands.

    Anyway, I moved the LCDout inside the Halfbridge sub and corrected the IF statement (<68 then freq=136). This helped much but not completely.

    The final solution was to remove the ISR alltogether. Seems there is something fundamentally wrong with my ISR setup.

    Ioannis
    Last edited by Ioannis; - 30th May 2025 at 23:31.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Erratic LED blinking

    In the ISR you have this:
    Code:
        if seconds<1000 then
            seconds=seconds+1
        else
            seconds=0
            Timer0=0    'Stop timer0
            TMR0H=$C1   'Load Timer 0 with start value $C187
            TMR0L=$87   'to count up 16000 steps until rollover
            Timer0=1    'Start timer0
    To me, this looks a bit strange - you're only reloading the TMR0 registers once every 1000 interrupts meaning that only the "first" period will be 1ms, then there will be 999 periods where the timer will freerun all the way from 0 to rollover.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default Re: Erratic LED blinking

    Nice catch...

    When someone shows you the stupid mistakes, its that moment you are embarrased a lot

    Ioannis
    Last edited by Ioannis; - 31st May 2025 at 20:28.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default Re: Erratic LED blinking

    And of course this explains the periodic error in the LED flashing...

    Ioannis

Similar Threads

  1. Blinking LED will not Blink
    By andybarrett1 in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 24th September 2014, 22:20
  2. PIC16F819 LED not blinking
    By ronbowalker in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 1st December 2009, 03:04
  3. blinking LED
    By kindows in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 31st July 2009, 17:08
  4. PIC18f452 blinking led ?
    By iugmoh in forum General
    Replies: 5
    Last Post: - 7th March 2008, 15:12
  5. Why is my LED not blinking?
    By Gary Goddard in forum General
    Replies: 14
    Last Post: - 1st January 2007, 21:23

Members who have read this thread : 12

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