Menu

Error compiling program

lhatch
2015-04-23
2015-04-23
  • lhatch

    lhatch - 2015-04-23

    I wrote a program to blink an LED after firing a ultra sonic module. I have not use interrupts yet, just pulse in. Anyway I get an error compiling, did not think I got it on another computer last night. Below is the code. I change echo to echo1 thinking reserved word, and use port A and B, but same error? Can someone compile this. I will add 7 segment via interrupt one I see this work. Error shows in ASM part.

    ASM Error[113] sonar.asm 130 : symbol not previously defined portb.1

    ~~~~

    chip 16F88,4

    config osc=int & WDT=OFF & BODEN=OFF & INTOSC_OSC_NOCLKOUT

    define TRIG PORTB.0

    define ECHO PORTB.1

    define LED PORTB.2

    Dir TRIG out
    Dir ECHO in
    Dir LED out

    DIM distance as word
    DIM pulsetime as word
    DIM i as word

    while 1 = 1

    gosub PINGIT
    gosub SHOWIT
    wait 5 s
    

    wend
    end

    PINGIT:

    'set off the pulse
    set TRIG off
    wait 100 msec
    set TRIG on
    wait 20 msec
    set TRIG off

    'wait for duration of echo
    pulsein pulsetime, ECHO, 1 usec
    distance=(pulsetime / 148)

    return

    SHOWIT:

    for i = 1 to distance
    set LED off
    wait 300 msec
    set LED on
    wait 300 msec
    next

    return

     

    Last edit: lhatch 2015-04-23
  • kent_twt4

    kent_twt4 - 2015-04-23

    What is the compiler version? Not seeing the PortB.1 problem with (0.9 28/4/2014).

    When posting code use the tildes (I use 4 ~'s) and paste the code in-between them. There needs to be a new line space before and after the tilde's.

    Check out Help for proper delay/wait syntax. A 20 MHz crystal could get past the compiler error for Pulsein inaccurate micro second delay.

    William Roth has an accurate Pulsein routine here: https://sourceforge.net/p/gcbasic/discussion/579126/thread/becaaf9a/?limit=25&page=1#2629
    I would use that, and the 8 MHz internal clock of the 16f88.

     

    Last edit: kent_twt4 2015-04-23
  • Anobium

    Anobium - 2015-04-23

    No errors. I change the Loop and corrected the pulsein but all seems good. You will get a warning on use of 1 us on frequency of less than 4mhz.

    This was tested and validated on GCB 0.94 on Windows. I am not sure of your version etc.

    Evan

    ~~~~
    #chip 16F88,4
    #config osc=int & WDT=OFF & BODEN=OFF & INTOSC_OSC_NOCLKOUT

    #define TRIG PORTB.0
    #define ECHO PORTB.1
    #define LED PORTB.2
    Dir TRIG out
    Dir ECHO in
    Dir LED out

    DIM distance as word
    DIM pulsetime as word
    DIM i as word

    do forever

      gosub PINGIT
      gosub SHOWIT
      wait 5 s
    

    loop
    end

    PINGIT:

    'set off the pulse
    set TRIG off
    wait 100 msec
    set TRIG on
    wait 20 msec
    set TRIG off

    'wait for duration of echo
    pulsein ECHO, pulsetime, 1 us
    distance=(pulsetime / 148)

    return

    SHOWIT:

    for i = 1 to distance
        set LED off
        wait 300 ms
        set LED on
        wait 300 ms
    next
    

    return

     
  • lhatch

    lhatch - 2015-04-23

    Thanks for the input guys. Turned out the pulsein was wrong. Will look at the Roth pulsein and bump the MHZ if the 16F628A will run 8MHZ. Just testing on the F88 until the 628A's get here.

    Thanks again.

     
  • lhatch

    lhatch - 2015-04-23

    FYI, the example on the http://gcbasic.sourceforge.net/help/ pulsein command was backwards and I used it backwards. The top part has it write though.

     

    Last edit: lhatch 2015-04-23
  • Anobium

    Anobium - 2015-04-23

    Yes. You were correct.

    This was corrected in Release v0.9ho of the Help File. If you upgrade to v0.94 this has the latest code and Help File.

    Evan

     
  • lhatch

    lhatch - 2015-04-23

    Thanks again Evan (and Kent), I looked for the new download and pulled the zip. I will update it today. So I should not use the online manual on source forge as there is a newer on in the updates?

     

    Last edit: lhatch 2015-04-23
  • Anobium

    Anobium - 2015-04-23

    The latest is in the Hot Release. I do not think I have made any changes this month.

    We will be making a drop when I get a moment, a few fixes etc. So... keep your eye on the wiki. A few more notices this weekend! :-)

    See https://sourceforge.net/p/gcbasic/news/

     

    Last edit: Anobium 2015-04-23
  • lhatch

    lhatch - 2015-04-23

    Will do. Can I just unzip the greatcowbasic over my greatcowbasic folder. I did not have the other stuff before? I have the old stuff and a c.bat that does the MLABASM and /k:a and I run from the command line? Or does the pickit 2 allow debugging? I use MPLABS now?

    Should I move this to a new thread?

     
    • Anobium

      Anobium - 2015-04-23

      Open a new thread. Others may ask the same in the future.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.