while wend problem


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107

    Default while wend problem

    This is a segment of my program. The PICBASIC compiler does not like my WHILE statement. What is wrong with it?
    REM PORT B ARE OUTPUT, INTERCEPT ON PORTA.1
    CMCON = %00001101
    VRCON = %11101100 'VREF ENABLED, OUTPUT ON FA2, V = 2.5V
    REM VREF ON RA2 WHICH IS ALSO INPUT TO COMPARATOR+
    REM COMPARITOR NEG INPUT ON RA1 IS INTERUPT INPUT, NORMALLY HIGH
    TRISA = %00000010 'PORTA.1 IS STOP INPUT, ALL OTHERS OUTPUT
    TRISB = %00000000 'ALL OUTPUTS

    ON INTERRUPT GOTO STOPSUB
    STOPSUB:
    WHILE PORTA.1 = 0 PAUSE 1 'WHY DOES THIS NOT WORK?
    WEND
    RESUME
    ENABLE

    Russ

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


    Did you find this post helpful? Yes | No

    Smile

    you have this
    WHILE PORTA.1 = 0 PAUSE 1 'WHY DOES THIS NOT WORK?
    WEND
    how about this?
    WHILE PORTA.1 = 0
    PAUSE 1 ' moved to its own line
    WEND
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

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


    Did you find this post helpful? Yes | No

    Smile

    and you do not appear to have a "DISABLE" before your INT routine, but you do have an "ENABLE" after it.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Just for info

    WHILE PORTA.1 = 0 PAUSE 1 'WHY DOES THIS NOT WORK?
    WEND
    Hi,

    You can also use a : to use multiple statements on the same line.
    Thus your code should be
    Code:
    WHILE PORTA.1 = 0 :PAUSE 1 'THIS WORKs !!!
    WEND
    Last edited by sougata; - 18th March 2007 at 05:10.
    Regards

    Sougata

  5. #5
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    Thanks. I am so used to GWBASIC that I expected PICBASIC to be the same.

    I don't know why I need an ENABLE or DISABLE, can't I just eliminate both?

    Russ

  6. #6
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Darrel has made working with interrupts so much easier with his Instant Interrupts. You might try this method.
    Last edited by rhino; - 19th March 2007 at 00:35.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  7. #7
    Join Date
    Jan 2006
    Location
    New Hampshire, USA
    Posts
    107


    Did you find this post helpful? Yes | No

    Default

    Thanks Ryan, I downloaded the files and it looks interesting but I don't have a clue what to do with them. Right now I need an interrupt and am looking for an easy fix. This is my program, it is a sequencer and the sequence works ok as long as the interrupt routine is not there. When the interrupt routine is there (ON INTERRUPT commented out), all the portb outputs are stuck low.

    REM PORT B ARE OUTPUT, INTERCEPT ON PORTA.1
    CMCON = %00001101 'COMPARATOR 2 USED, C1 DISABLED
    VRCON = %11101100 'VREF ENABLED, OUTPUT ON RA2(PIN1), V = 2.5V

    TRISA = %00000010 'PORTA.1 IS STOP INPUT
    TRISB = %00000000 'ALL OUTPUTS

    'ON INTERRUPT GOTO STOPSUB
    STOPSUB:
    WHILE PORTA.1 = 0 : STOP : WEND
    RESUME

    REM SET OUTPUTS HIGH INITIALLY
    HIGH PORTB.0 : HIGH PORTB.1 : HIGH PORTB.2 : HIGH PORTB.3
    HIGH PORTB.4 : HIGH PORTB.5 : HIGH PORTB.6 : HIGH PORTB.7

    START:
    LOW PORTB.0 : PAUSE 5000 : HIGH PORTB.0
    LOW PORTB.1 : PAUSE 5000 : HIGH PORTB.1
    LOW PORTB.2 : PAUSE 5000 : HIGH PORTB.2
    LOW PORTB.3 : PAUSE 5000 : HIGH PORTB.3
    LOW PORTB.4 : PAUSE 5000 : HIGH PORTB.4
    LOW PORTB.5 : PAUSE 5000 : HIGH PORTB.5
    LOW PORTB.6 : PAUSE 5000 : HIGH PORTB.6
    LOW PORTB.7 : PAUSE 5000 : HIGH PORTB.7
    GOTO START
    END

  8. #8
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Hey Russ -
    Either I'm blind, or you don't have any interrupts enabled. Read through the threads on Darrel's instant interrupt routines. It's well documented, and there are plenty of examples. If I'm blind.... please point out where you are INTCON register. To be honest... I haven't played around with them much, but I'll try to help if I can.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

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


    Did you find this post helpful? Yes | No

    Talking

    Hi Russ,
    If stopsub is activated, will not all useful activity cease due to the STOP command ? As I see it the program will never WEND or RESUME, unless I misunderstand page 152 of TFM.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  10. #10
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Good point Joe... I didn't even see that.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. HSEROUT and Commas, What? Help Me Understand
    By altech6983 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 20th July 2009, 19:12
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. Problem with WHILE - WEND
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 31st May 2006, 02:05
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

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