LED Blinking while main does something else


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    May 2015
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: LED Blinking while main does something else

    Hello Robert,

    When compiling the Blinky code I get these ASM errors, using PBP3 (MPLABX IDE) with PIC16f628. Any ideas on the errors?

    Name:  Untitled.png
Views: 1900
Size:  12.6 KB

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,722


    Did you find this post helpful? Yes | No

    Default Re: LED Blinking while main does something else

    as the error message suggests , add these lines to your code

    wsave VAR BYTE $70 SYSTEM ' location for W if in bank0
    wsave1 VAR BYTE $A0 SYSTEM ' location for W if in bank1
    wsave2 VAR BYTE $120 SYSTEM ' location for W if in bank2

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: LED Blinking while main does something else

    I've never used the Button command before but here's something simple to try.
    You'll probably need to modify your readbutton routines so it returns to the Main loop after testing for button activity.

    Code:
    x VAR BYTE
    
    main:
    High LED5 ' Turn on LED connected to PORTB.0
    
    FOR x = 0 TO 250  ' Loop here for 1 second while monitoring
      PAUSE 4
      GOSUB readbutton1
      GOSUB readbutton2
    NEXT x
    
    Low LED5 ' Turn off LED connected to PORTB.0
    
    FOR x = 0 TO 250  ' Loop here for 1 second while monitoring
      PAUSE 4
      GOSUB readbutton1
      GOSUB readbutton2
    NEXT x
    
    GOTO main
    
    
    readbutton1:
      Button bt1,0,40,0,B1,0,readbutton2      ' main instead of redabutton2?
      Toggle LED1 ' Toggle LED if pressed
    RETURN
    
    readbutton2:
      Button button2,0,40,0,B2,0,readbutton1   ' main instead of redabutton1?
      Toggle LED2 ' Toggle LED if pressed
    RETURN
    
    END
    Louie

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


    Did you find this post helpful? Yes | No

    Default Re: LED Blinking while main does something else

    just read the "DT interrupts" file comments header....

    explanation is there !

    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 " !!!
    *****************************************

Similar Threads

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

Members who have read this thread : 0

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