Frequently Asked Questions

Why doesn’t anything come up when I run GCBASIC.exe?

GCBASIC IS a command line compiler. To compile a file, you can drag and drop it onto the GCBASIC.exe icon.

If you use an Integrated Development Environment (IDE) you can edit your program and press an ICON to send the program to the chip. Several are listed on the GCBASIC website.

The recommended IDE for Windows is GCCODE.



What Microchip PIC, Atmel AVR or LGT microcontrollers does GCBASIC support?

Hopefully, all 8 bit Microchip PIC, Atmel AVR and LGT microcontrollers and (those in the PIC10, PIC12, PIC16 and PIC18 families). If you find one that GCBASIC does not work with properly, please post about it in the Compiler Problems section of the GCBASIC forum.

Is GCBASIC case sensitive?

No! For example, Set, SET, set, SeT, etc are all treated exactly the same way by GCBASIC.

Can I specify the bit of a variable to alter using another variable?

GCBASIC support bitwise assignments. As follows:

    portc.0 = !porta.1

You can also use a shift function. As in other languages, by using the Shift Function FnLSL. AN example is:

    MyVar = FnLSL( 1, BitNum)`  is Equivalent to `MyVar = 1<<BitNum`

To set a bit of a port and to prevent glitches during operations, use #option volatile as folllows.

    'add this option for a specific port.
    #option volatile portc.0

    'then in your code
    portc.0 = !porta.1

To set a bit of a port or variable. Encapsulate it in the SetWith method, this also eliminates any glitches during the update, use this method.

    SetWith(MyPORT, MyPORT OR FnLSL( 1, BitNum))

To clear a bit of a port, use this method.

    MyPORT = MyPORT AND NOT FnLSL( 1, BitNum))

To set a bit within an array, use this method.

    video_buffer_A1(video_adress) = video_buffer_A1(video_adress) OR FnLSL( 1, BitNum)

To set a bit within a variable, use this method.

    Dim my_variable as byte
    Dim my_bit_address_variable as byte

    'example
    my_variable = 0
    my_bit_address_variable = 7

    my_variable.my_bit_address_variable = 1   ' where 1 or 0 or any bit address is valid

    'Sets bit 7 of my_variable therefore 128

See also Set, FnLSL, FnLSR and Rotate

Why is x feature not implemented?

Because it has not been thought of, or no-one has been able to implement it!

If there are any features that you would like to see in GCBASIC, please post them in the "Open Discussion" section of the GCBASIC forum. Or, if you can, have a go at adding the feature yourself!

When using an include file does this use lots of memory?

When using include files, for instance the <ds3231.h> include, if you are not using all the functions of the include file, GCBASIC knows not to include the unused functions within the user program when compiling.

If I am using the hardware I2C, does all the code related to hardware I2C still get compiled in the code?

GCBASIC only compiles functions and subroutines if they are called. GCBASIC starts by compiling the main routine, then anything called from there. Each time it finds a new subroutine that is called, it compiles it and anything that it calls. If a subroutine is not needed, it does not get compiled.

My LCD will not operate as expected?

Try adding. #define LCD_SPEED SLOW

This will slow the writing to the LCD.

Atmel AVR memory usage displayed is incorrect?

Atmel AVR memory values are specified in WORDS in GCBASIC. The GCBASIC compiler uses words, not bytes, for consistency between Microchip PIC and Atmel AVR microcontrollers. This keeps parts of the compiler simpler.

I cannot open the Window Help File?

See http://digital.ni.com/public.nsf/allkb/B59D2B24D624B823862575FC0056F3D0

How do I revert the FOR-NEXT loop to the Legacy FOR-NEXT method ?

Some background.   In 2021 the GCBASIC compiler was updated to improve the operation of the FOR-NEXT loop.   The improvement did increase the size of the ASM generated.   The legacy FOR-NEXT loop had some major issues that included never ending loops, incorrect end loop and unexpected operations.   This was all caused by the compiler, not the user, and in 2021 the compiler was updated to resolve these issues.  

However, there is a risk that the new FOR-NEXT method causes 1) larger ASM that will not fit in small microcontrollers or 2) the new code does not operate as expected.   In either case you can disable the new FOR-NEXT method by adding a constant as shown below.   Adding this constant will revert the FOR-NEXT loop asm generated to the legacy method.  

    #DEFINE USELEGACYFORNEXT