Other directives

The built-in #defines are used to support the #IFDEF command set are as follows. The table also shows which #defines are supported as string in HSerPrint, SerPrint and other string related commands.

Constants Type Usage Decription

CHIPADC

Constant

Conditional compilation or output commands

The number of A/D inputs on the current chip

CHIPASSEMBLER

Constant

Conditional compilation or output commands

The select assemble GCASM/MPASM/PICAS etc

CHIPEEPROM

Constant

Conditional compilation or output commands

The number of Bytes in EEPROM memmory

CHIPIO

Constant

Conditional compilation or output commands

The number of general purpose IO pins

CHIPMHZ

Constant

Conditional compilation or output commands

The microcontroller clock speed

CHIPNAME

Constant

Conditional compilation only

The microcontroller type

CHIPNAMESTR

Constant

Conditional compilation or output commands

The microcontroller name

CHIPPINS

Constant

Conditional compilation or output commands

The number of microcontroller pins.

CHIPRESERVEHIGHPROG

Constant

Scripts, Conditional compilation, and output commands

The value of the words reserved

CHIPOSC

Constant

Scripts, Conditional compilation, and output commands

The frequency selected

CHIPUSINGINTOSC

Constant

Scripts, Conditional compilation, and output commands

The constant exists if the compiler has deternined the program is using the internal oscillator

CHIPPROGRAMMERNAMESTR

String constant

Name of the chip type to be used by a programmer

The psuedo microcontroller type

CHIPRAM

Constant

Conditional compilation or output commands

The RAM size

CHIPSHAREDRAM

Constant

Conditional compilation or output commands

The first RAM location

CHIPFAMILY

Constant

Conditional compilation or output commands

See the table below

CHIPWORDS

Constant

Conditional compilation or output commands

The number of WORDS in Flash memmory

SOURCEFILE

Constant string

Conditional compilation or output commands

The name of the source GCB file

       

Function

Type

Usage

Description

Var()

Function

Conditional compilation only

True if a register is declared (or false if not declared) in the currently specficied microcontroller’s .dat file.

Var(register_name)

NoVar()

Function

Conditional compilation only

True if a register is NOT declared (or false if declared) in the currently specficied microcontroller’s .dat file.

NoVar(register_name)

Bit()

Function

Conditional compilation only

True if a bit is declared (or false if not declared) in the currently specficied microcontroller’s .dat file.

Bit(bit_name)

NoBit()

Function

Conditional compilation only

True if a bit is NOT declared (or false if declared) in the currently specficied microcontroller’s .dat file.

NoBit(bit_name)

Allof()

Function

Conditional compilation only

True if all defines are declared:

AllOf(define1, define2, …)

OneOf()

Function

Conditional compilation only

True if one of the defines is declared:

OneOf(define1, define2, …)



The table below shows two special directives that support the mapping for one variable or bit to anoher variable or bit. This is useful when creating portable code or libraries to ensure GCBASIC



Directive Explanation Usage

#samebit

The compiler checks each item in the list to see which ones are implemented on the current microcontroller.
If any of the bits do not exist, the compiler will create a constant mapping to the name of the first parameter in the list of parameters that does exist. + If none of the bits exist the no constant is created.

  #samebit PLLEN, SPLLEN, SPLLMULT
    Set SPLLEN On

#samevar

The compiler checks each item in the list to see which ones are implemented on the current microcontroller.
If any of the variables do not exist, the compiler will create a constant mapping to the name of the first parameter in the list of parameters that does exist. + If none of the variables exist the no constant is created.

  #samevar CMCON, CMCON0, CMCONbob
  #ifdef Var(CMCONbob)
      CMCONbob = 7
  #endif

  Compiles to:
  ;CMCONbob = 7
  movlw 7
  movwf CMCON,ACCESS



This table shows the ChipFamily constants mapped to the microcontroller architecture.

ChipFamily Value Microcontroller Characteristics

PIC

 

100

AVR core version V0E class microcontrollers

110

AVR core version V1E class microcontrollers

120

AVR core version V2E class microcontrollers

-120 Subtype: 121

AVR core version AVR8L, also called AVRrc, reduced core class microcontrollers. ATTiny4-5-9-10 and ATTiny102-104 with only 16 GPR’s from r16-r31 and only 54 instructions.

-120 Subtype: 122

LGT microcontrollers.

-120 Subtype: 123

AVR core version V2E class microcontrollers with one USART like the mega32u4, mega16u4 - they have different registers for the usart.

121

Tiny4-5-9-10 and tiny102-104. Only 16 GPR’s from r16-r31 and only 54 instructions.

130

AVR core version V3E class microcontrollers but essentially the mega32u6 only

   

AVR

 

12

Baseline devices. 12 Bit instruction set

15

Mid-range core devices. 14 Bit instruction set with enhanced instruction set class

15 plus familyVariant=1

Mid-range core devices. 14 Bit instruction set with enhanced instruction set and with large memory capability class

16

High end core devices. 16 Bit instruction set, memory addressing architecture and an extended instruction set.

Chip family 16 also have a sub chip family Constant.   These constants are shown below:

    ChipFamily18FxxQ10 = 16100

    ChipFamily18FxxQ43 = 16101

    ChipFamily18FxxQ41 = 16102

    ChipFamily18FxxK42 = 16103

    ChipFamily18FxxK40 = 16104

    ChipFamily18FxxQ40 = 16105

    ChipFamily18FxxQ84 = 16106

    ChipFamily18FxxK83 = 16107

    ChipFamily18FxxQ83 = 16108