[SOLVED !] Please Tell me why this does not work! :) Am I wrong or is the compiler wrong ?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Ashfaq
    Guest Ashfaq's Avatar

    0 Not allowed!

    Question Please Tell me why this does not work! :) Am I wrong or is the compiler wrong ?

    Hello All

    I tried the following code on a FireWing board which I got setup on Proton24 fairly painlessly (or less pain than I expected after it enumerated as a Teensy board!, which I solved by manually pointing to the right driver).

    Code:
    Device = 24FJ64GA002Declare Xtal = 32
    
    
    Declare Hserial1_Baud = 9600 
    
    
    Dim Led As PORTB.14
    
    
    While 1
    High Led
    DelayMS 500
    Low Led
    DelayMS 500 
    
    
    HSerOut ["Hello"]    ;<< Works OK if this is not there!
    Wend

    I get no compilation errors or programming errors at all.

    Please note that the above code works just fine if I dont have the Hserout command there! This code is a mod of the very useful (Thanks very much) help post by David Barker, which saved me a lot of time. http://www.protonbasic.co.uk/archive...p/t-70571.html

    Then, here is the odd bit. I (for some reason) tried removing the While 1 and Wend commands and used GOTO.... as following:

    Code:
    Device = 24FJ64GA002Declare Xtal = 32
    
    
    Declare Hserial1_Baud = 9600 
    
    
    Dim Led As PORTB.14
    
    
    main:
    ;While 1
    
    
    High Led
    DelayMS 500
    Low Led
    DelayMS 500 
    
    
    HSerOut ["Hello"]
    ;Wend
    
    
    GoTo main

    Good programmers tell me that using GOTO statements are not good practice and bad things will happen if I use them. But this is totally out of my understanding as to why the code on the top stops working just because of the Hserout command. But then the same code will work if I use GOTO!

    Any help here will be really appreciated.

    Thanks

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,415
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: Please Tell me why this does not work! :) Am I wrong or is the compiler wrong ?

    Hello Ashfaq

    I'm not sure what the line "While 1" is doing. I think it should be "While 1=1" or just "While". No idea about the HRSOUT I'm afraid.

    Charlie

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Ashfaq
    Guest Ashfaq's Avatar

    0 Not allowed!

    Default Re: Please Tell me why this does not work! :) Am I wrong or is the compiler wrong ?

    Thanks Charlie.

    I will try the code with While 1 = 1 as you rightly said and see if it makes a difference.

    If nothing else, I will just use GOTOs!

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Prolific Poster hadv215's Avatar
    Join Date
    Sep 2009
    Posts
    1,136
    Thumbs Up
    Received: 66
    Given: 26
    Total Downloaded
    3.61 GB

    0 Not allowed!

    Default Re: Please Tell me why this does not work! :) Am I wrong or is the compiler wrong ?

    Using a GoTo as in
    Code:
    MainLoop:
    ..
    ..
    ..
    GoTo MainLoop
    or
    Code:
    aProcedure:
    ...
    GoTo end_of_procedure
    ...
    ...
    end_of_procedure:
    return
    isn't very bad programming practice. The risks with GoTo's is when they cross each other. Like this:
    Code:
    label1:
    if b = 3 then 
    goto label3
    endif
    label2:
    if c = 4 then
    goto label4
    endif
    label3:
    if a = 3 then 
    goto label1 
    else 
    goto label2
    endif
    label4:
    goto label1
    Last edited by hadv215; 3rd April 2014 at 17:35.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,599
    Thumbs Up
    Received: 341
    Given: 162
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: Please Tell me why this does not work! :) Am I wrong or is the compiler wrong ?

    A couple of questions before I can give any assistance.

    Q1).
    The FireWing board usually comes equipped with a PIC24HJ128GP502 device. Have you added the PIC24FJ64GA002 device, or is it a special build from Dave?

    Q2).
    Are you bootloading the program onto the device or using a device programmer?

    FYI. Whatever is causing the issue it's not any GoTos or While loops, or the compiler. But I need some clarificaton from the above questions before I can continue.
    Last edited by top204; 3rd April 2014 at 19:04.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Ashfaq
    Guest Ashfaq's Avatar

    0 Not allowed!

    Default Re: Please Tell me why this does not work! :) Am I wrong or is the compiler wrong ?

    Hello All


    Thanks Les


    You were right, I was using the WRONG device! Sorry. I just assumed that the example posted here was for the firewing... so just copied and used it. http://www.protonbasic.co.uk/archive...p/t-70571.html


    The other thing that I was doing wrong was just using the statement while 1.. rather than while 1 = 1


    Some interesting observations:






    If I use while 1 (which I know is not right.. but it compiles); the code works OK (i.e. flashes the LED) if I DONT have the HSEROUT statement; if I do.. then it just doest work.


    so this does NOT work:


    Code:
    Device = 24HJ128GP502 
    Declare Xtal = 32
    Declare Hserial1_Baud = 9600 
    
    Dim Led As PORTB.14
    
    While 1
    
    High Led
    DelayMS 500
    Low Led
    DelayMS 500 
    
    HSerOut ["Hello"]
    Wend

    and this 'Works', Hserout line commented out:

    Code:
    Device = 24HJ128GP502 
    Declare Xtal = 32
    Declare Hserial1_Baud = 9600 
    
    Dim Led As PORTB.14
    
    While 1
    
    High Led
    DelayMS 500
    Low Led
    DelayMS 500 
    
    ;HSerOut ["Hello"]
    
    Wend

    If I use WHILE 1 = 1; it all works as expected.


    So this is OK (as we would expect):

    Code:
    Device = 24HJ128GP502 
    Declare Xtal = 32
    
    Declare Hserial1_Baud = 9600 
    
    Dim Led As PORTB.14
    
    While 1 = 1
    
    High Led
    DelayMS 500
    Low Led
    DelayMS 500 
    
    HSerOut ["Hello"]
    Wend
    BTW, I am using the Bootloader via USB and not a programmer.
    Last edited by Ashfaq; 4th April 2014 at 12:29. Reason: missing information

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. dropdownlists wrong?
    By Puffeltje in forum Fuse Configurator
    Replies: 2
    Last Post: 7th April 2019, 20:32
  2. What is wrong?
    By laserline in forum Proton Plus Compiler v3
    Replies: 11
    Last Post: 14th December 2008, 13:31
  3. What's wrong with my for next loop???
    By SimonJA in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 19th December 2006, 18:37
  4. Wrong value return...
    By fanie in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 22nd July 2006, 01:29
  5. [SOLVED !] Something wrong with the keypad?
    By Pairair in forum Proton Development Board
    Replies: 9
    Last Post: 29th November 2004, 16:35

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts