By Category

Analog/Digital conversion

Command Summary

ADFormat (Deprecated - Do not use)

ADFormat ( Format_Left | Format_Right )

ADOff

This command is obsolete. There should be no need to call it. GCBASIC

Analog/Digital Conversion Code Optimisation

The analog to digital converter (ADC or A/D) module support is implemented by GCBASIC to provide 8-bit, 10-bit and 12-bit Single channel …​

Analog/Digital Conversion Overview

The analog to digital converter (ADC or A/D) module support is implemented by GCBASIC to provide 8-bit, 10-bit and 12-bit Single channel …​

ReadAD

For a normal ( also called a Single Channel ) read use.

ReadAD10

For a normal ( also called a Single Channel ) read use.

ReadAD12

For a normal ( also called a Single Channel ) read use.

Pot

Pot pin, output

Bitwise

Command Summary

Bitwise Operations Overview

GCBASIC (as with most other microcontroller programming languages) supports bitwise operations.

FnLSL

BitsOut = FnLSL(BitsIn, NumBits)

FnLSR

BitsOut = FnLSR(BitsIn, NumBits)

SetWith

SetWith(TargetBit, Source)

MCU EEPROM ( DFM )

Command Summary

Dataset for EEPROM

EEPROM DataSetName [[,]address]

EPRead

EPRead location, store

EPWrite

EPWrite location, data

HEFM ( PFM )

Command Summary

HEFEraseBlock

HEFEraseBlock ( block_number )

HEFM Overview

Some enhanced mid-range Microchip PIC devices support High-Endurance Flash (HEF) memory. These devices lack the data EEPROM found on othe…​

HEFRead

'as a subroutine

HEFReadBlock

HEFReadBlock ( block_number, buffer(), [, num_bytes] )

HEFReadWord

'as a subroutine

HEFWrite

HEFWrite ( location, data )

HEFWriteBlock

HEFWriteBlock ( block_number, buffer(), [, num_bytes] )

HEFWriteWord

HEFWriteWord ( location, data_word_value )

PROGMEM ( PFM )

Command Summary

DATA

DATA DataSetName [as Byte | Word]

PFMRead

PFMRead (location, store)

PFMWrite

PFMWrite (location, value)

ProgramErase

ProgramErase (location)

ProgramRead

ProgramRead (location, store)

ProgramWrite

ProgramWrite (location, value)

PROGMEM ( MCU Configuration )

Command Summary

DeviceConfigurationRead

deviceconfigurationRead (location, store)

SAFM

Command Summary

SAFEraseBlock

SAFEraseBlock ( block_number )

SAFM Overview

Some Advanced (18F) and some Enhanced Mid-Range (16F) Microchip PIC devices support Storage Area Flash (SAF) memory. These devices also i…​

SAFRead

'as a subroutine

SAFReadBlock

SAFReadBlock ( block_number, buffer(), [, num_bytes] )

SAFReadWord

'as a subroutine

SAFWrite

SAFWrite ( location, data )

SAFWriteBlock

SAFWriteBlock ( block_number, buffer(), [, num_bytes] )

SAFWriteWord

SAFWriteWord ( location, data_word_value )

EERAM ( Device )

Command Summary

47xxx EERam Devices

This section covers the 47xxx EERam devices.

SRAM ( Device )

Command Summary

SRAM Overview

Serial SRAM is a standalone volatile memory that provides an easy and inexpensive way to add more RAM to application. These are 8-pin low…​

SRAMRead

SRAMRead location, store

SRAMWrite

SRAMWrite location, data

Flow control

Command Summary

Do

Do [{While | Until} condition]

End

End

Exit

Exit Sub | Exit Function | Exit Do | Exit For | Exit Repeat

For

For counter = start To end [Step increment]

Gosub

Gosub label

Goto

Goto label

If

If condition Then command

IndCall

IndCall Address

Pause

Pause time_ms

Repeat

Repeat times

Select

Select Case var

Wait

Wait time units

Fixed Voltage Reference

Command Summary

FVRInitialize

FVRInitialize ( FVR_OFF | FVR_1x | FVR_2x | FVR_4x )

FVRIsOutputReady

user_var = FVRIsOutputReady()

Interrupts

Command Summary

Interrupts overview

Interrupts are a feature of many microcontrollers. They allow the

IntOff

IntOff

IntOn

IntOn

On Interrupt

On Interrupt event Call handler

On Interrupt: The default handler

GCBASIC supports a default interrupt handler in two modes:

Keypad

Command Summary

Keypad Overview

The keypad routines allow for a program to read from a 4 x 4 matrix

KeypadData

var = KeypadData

KeypadRaw

largevar = KeypadRaw

Graphical LCD

Command Summary

Box

Box(LineX1,LineY1, LineX2, LineY2 [, LineColour ] )

Circle

Circle(XPixelPosition, YPixelPosition, Radius [ [,Optional LineColour] [,Optional Rounding] ] )

Ellipse

Ellipse(XPixelPosition, YPixelPosition, XRadius, YRadius [,Optional LineColour] )

e-Paper Controllers

This section covers GLCD devices known as e-Papers.

FilledBox

FilledBox(LineX1,LineY1, LineX2, LineY2, Optional LineColour = 1)

FilledCircle

FilledCircle(XPixelPosition, YPixelPosition, Radius [,Optional LineColour] )

FilledEllipse

FilledEllipse(XPixelPosition, YPixelPosition, XRadius, YRadius [,Optional LineColour] )

FilledTriangle

FilledTriangle( XPixelPosition1, YPixelPosition1, XPixelPosition2, YPixelPosition2, XPixelPosition3, YPixelPosition3 [,Optional LineColou…​

Fonts and Characters

This section covers GLCD fonts and characters.

GLCD Overview

The GLCD commands are used to control a Graphical Liquid Crystal Display (GLCD)

GLCDCLS

GLCDCLS [GLCDBackground]

GLCDDisplay

GLCDDisplay Off | On

GLCDDrawChar

GLCDDrawChar(CharLocX, CharLocY, CharCode [, Optional Colour] )

GLCDDrawString

GLCDDrawString(CharLocX, CharLocY, String [, Optional Colour] )

GLCDLocateString

GLCDLocateString(PrintLocX, PrintLocY )

GLCDPrint

GLCDPrint(PrintLocX, PrintLocY, PrintData_Byte [, Optional Colour] ) ',or

GLCDPrintLargeFont

GLCDPrintLargeFont( PrintLocX, PrintLocY, PrintData_String [, Optional Colour] )

GLCDPrintString

GLCDPrintString( String )

GLCDPrintStringLn

GLCDPrintStringLn( String )

GLCDPrintWithSize

GLCDPrintWithSize(PrintLocX, PrintLocY, PrintData_Byte , FontSize [, Color ] ) ',or

GLCDReadByte

byte_variable = GLCDReadByte

GLCDRotate

GLCDROTATE LANDSCOPE | PORTRAIT_REV | LANDSCAPE_REV | PORTRAIT

GLCDTimeDelay

GLCDTime

GLCDTransaction

GLCD_Open_PageTransaction

GLCDWriteByte

GLCDWriteByte (LCDByte)

HX8347G Controllers

This section covers GLCD devices that use the HX8347G graphics controller.

Hyperbole

Hyperbole (x, y, a_axis, b_axis, type, ModeStop, optional LineColour=GLCDForeground)

ILI9326 Controllers

This section covers GLCD devices that use the ILI9326 graphics controller. The ILI9326 is a TFT LCD Single Chip Driver with 400RGBx320 Re…​

ILI9340 Controllers

This section covers GLCD devices that use the ILI9340 graphics controller. The ILI9340 is a TFT LCD Single Chip Driver with 240RGBx320 Re…​

ILI9341 Controllers

This section covers GLCD devices that use the ILI9341 graphics controller. The ILI9341 is a TFT LCD Single Chip Driver with 240RGBx320 Re…​

ILI9481 Controllers

This section covers GLCD devices that use the ILI9481 graphics controller.

ILI9486(L) Controllers

This section covers GLCD devices that use the ILI9486(L) graphics controller.

ILI9488 Controllers

This section covers GLCD devices that use the ILI9488 graphics controller.

KS0108 Controllers

This section covers GLCD devices that use the KS0108 graphics controller.

Line

Line(LineX1,LineY1, LineX2, LineY2, Optional LineColour = 1)

NEXTION Controllers

This section covers GLCD devices that use the serially attached Nextion graphics displays.

NT7108C Controllers

This section covers GLCD devices that use the NT7108C graphics controller.

Parabola

Parabola (x, y, p_factor, type, modestop, optional LineColour=GLCDForeground)

PCD8544 Controllers

This section covers GLCD devices that use the PCD844 graphics controller.

Pset

PSet(XPosition, YPosition, GLCDState)

SDD1289 Controllers

This section covers GLCD devices that use the SDD1289 graphics controller. The SDD1289 is a 240 x 320 single chip controller driver IC fo…​

SH1106 Controllers

This section covers GLCD devices that use the SH1106 graphics controller. THe SH1106 is a single-chip CMOS OLED/PLED driver with controll…​

SSD1306 Controllers

This section covers GLCD devices that use the SSD1306 graphics controller.

SSD1331 Controllers

This section covers GLCD devices that use the SSD1331 graphics controller. The SSD1331 is a single-chip controller/driver for 262K-color,…​

SSD1351 Controllers

This section covers GLCD devices that use the SSD1351 graphics controller. The SSD1351 is a single-chip controller/driver for 262K-color,…​

ST7567 Controllers

This section covers GLCD devices that use the ST7567 graphics controller.

ST7735 Controllers

This section covers GLCD devices that use the ST7735 graphics controller. The ST7735 or ST7735R is a single-chip controller/driver for 26…​

ST7789 Controllers

This section covers GLCD devices that use the ST7789 graphics controller. The ST7789 is a TFT LCD Single Chip Driver with 240x240 or 320x…​

ST7920 Controllers

This section covers GLCD devices that use the ST7920 graphics controller.

T6963 Controllers

This section covers Graphical Liquid Crystal Display (GLCD) devices that use the Toshiba T6963 graphics controller. The T6963 is a monoch…​

Triangle

Triangle(XPixelPosition1, YPixelPosition1, XPixelPosition2, YPixelPosition2, XPixelPosition3, YPixelPosition3 [,Optional LineColour] )

UC1601 Controllers

This section covers GLCD devices that use the UC1601 graphics controller.

Touch Screen

Command Summary

ADS 7843 Serial Driver

ADS7843_Init

Liquid Crystal Display

Command Summary

CLS

CLS

Get

var = Get(Line, Column)

LCD Overview

The LCD routines in this section allow GCBASIC programs to control an

LCDBacklight

LCDBacklight ( On | Off )

LCDCmd

LCDCMD value

LCDCreateChar

LCDCreateChar char, chardata()

LCDCreateGraph

LCDCreateGraph value

LCDCursor

LCDCursor value

LCDDisplayOff

LCDDisplayOff

LCDDisplayOn

LCDDisplayOn

LCDHex

LCDHex value

LCDHome

LCDHome

LCDSpace

LCDSpace value

LCDWriteChar

LCDWriteChar char

Locate

Locate Line, Column

Print

Print string

Put

Put Line, Column, Character

Pulse width modulation

Command Summary

ATMEL AVR PWM Overview

The methods described in this section allow the generation of Pulse

Hardware PWM Code Optimisation

For compatibility all channels are supported by default. This is maintains backward compatibility.

HPWM 10 Bit

HPWM channel, frequency, duty cycle, timer [, resolution]

HPWM 16 Bit

HPWM16 channel, frequency, duty cycle 'Enable a 16-bit PWM channel'

HPWM AVR OCRnx

HPWM channel, frequency, duty cycle

HPWM CCP

HPWM channel, frequency, duty cycle

HPWM Fixed Mode

PWMOn 'only applies to CCP/PWM channel 1

HPWM Fixed Mode for AVR

PWMOn

HPWM_CCPTimerN

HPWM_CCPTimerN channel, frequency, duty cycle [, timer 2, 4 or 6 ]

HPWMOff

HPWMOff ( channel ) 'selectively turn off the CCP channel

HPWMOff

HPWMOff ( channel, PWMHardware )

HPWMOff

HPWMOff ( channel ) 'selectively turn off the CCP channel

HPWMUpdate for CCP/PWM Modules(s)

HPWMUpdate ( channel, duty_cycle )

HPWMUpdate for PWM Module(s)

HPWMUpdate ( channel, duty_cycle )

Microchip PIC PWM Overview

The methods described in this section allow the generation of Pulse

PWM Software Mode

PWMOut channel, duty cycle, cycles

PWMOff

PWMOff

PWMOff for AVR

PWMOff

PWMOn

PWMOn

PWMOn for AVR

PWMOn

PWMOut

PWMOut channel, duty cycle, cycles

PulseOut

PulseOut pin, time units

PulseOutInv

PulseOutInv pin, time units

PulseIn

PulseIn pin, user_variable, time units

PulseInInv

PulseInInv pin, user_variable, time units

Random Numbers

Command Summary

Overview

These routines allow GCBASIC to generate pseudo-random numbers.

Random

var = Random

Randomize

Randomize

7-Segment Displays

Command Summary

7 Segment Displays - Legacy

The GCBASIC 7 segment display methods make it easier for GCBASIC programs to display numbers and letters on 7 segment LED displays.

7 Segment Displays - TM1637 4 Digits

The TM1637 disaplay module is used for displaying numbers on a keyboard matrix.

7 Segment Displays - TM1637 6 Digits

The TM1637 display module is used for displaying numbers on a keyboard matrix.

7 Segment Displays Overview

The 7 Segment Displays module provide a cheap red, green, blue or white bright LED Display.

Common Anode

This is a Common Anode 7 Segment display example.

Common Cathode

This is a Common Cathode 7 Segment display example.

DisplayChar

DisplayChar (display, character, dot)

DisplaySegment

DisplayValue (display, data)

DisplayValue

DisplayValue (display, data, dot)

TM_Bright

TM_Bright = Brightness

TM_Bright

TM_Bright = Brightness

TM_Point

TM_Point = (Point)

TMDec

TMDec Value [, Options ]

TMDec

TMDec Value [, Options ]

TMHex

TMHex Value

TMHex

TMHex Value

TMWrite4Dig

TMWrite4Dig (dig1, dig2, dig3, dig4 [, Brightness ], Colon ] ] )

TMWrite6Dig

TMWrite6Dig (dig1, dig2, dig3, dig4, dig5, dig6, Brightness, Point)

TMWriteChar

TMWriteChar ( TMaddr, TMchar )

TMWriteChar

TMWriteChar ( TMaddr, TMchar )

One Wire Devices

Command Summary

DS18B20

The DS18B20 is a 1-Wire digital temperature sensor from Maxim IC.

DS18B20SetResolution

For Single Channel/Device only. The method assumes a single DS18B20 device on the OneWire bus.

ReadDigitalTemp

ReadDigitalTemp

ReadTemp

byte_var = ReadTemp

ReadTemp12

byte_var = ReadTemp12

Serial Communications

Command Summary

HSerGetNum

HSerGetNum myNum ‘Gets a multi digit number from USART 1

HSerGetString

HSerGetString myString ‘Get a multi char string from USART 1

HSerPrint

HSerPrint user_value [,1|2|3|4] 'Choose comport with optional parameter

HserPrintByteCRLF

HserPrintByteCRLF user_data [, 1 | 2 | 3 | 4 ]

HserPrintCRLF

HserPrintCRLF [optional BYTE] [, 1 | 2 | 3 | 4 ]

HSerPrintStringCRLF

HSerPrintStringCRLF user_string [,1|2|3|4] 'Choose comport with optional parameter

HSerReceive

HSerReceive (user_byte_variable)

HSerReceiveFrom

user_byte = HSerReceiveFrom [,1 | 2 | 3 | 4]

HSerSend

HSerSend user_byte [,1|2|3|4] 'Choose comport with optional parameter

HSerSendBytes

HSerSendBytes(byte1, byte2 [, byte3 …​ up to byte16])

InitSer

InitSer channel, rate, start, data, stop, parity, invert

RS232 Hardware Overview

GCBASIC support programs to communicate easily using RS232.

RS232 Software Overview

These routines allow the microcontroller to send and receive RS232 data.

RS232 Software Overview - Optimised

These routines allow the microcontroller to send and receive RS232 data.

SerNPrint

Ser1Print value

SerNReceive

bytevar = Ser1Receive

SerNSend

Ser1Send data

SerPrint

SerPrint channel, value

SerReceive

SerReceive channel, output

SerSend

SerSend channel, data

Infrared Remote Control

Command Summary

NEC Remote Control

NECSend address, data

RC5 Remote Control

RC5Send address, data

PS/2

Command Summary

InKey

output = InKey

PS/2 Overview

These routines make it easier to communicate with a PS/2 device,

PS2ReadByte

output = PS2ReadByte

PS2SetKBLeds

PS2SetKBLeds (LedStatus)

PS2WriteByte

PS2WriteByte user_data

SPI

Command Summary

FastHWSPI2Transfer

FastHWSPI2Transfer tx

FastHWSPITransfer

FastHWSPITransfer tx

SPI Overview

The SPI interface allows for the transmission and receiption of data simultaneously on two lines (MOSI and MISO).

SPI2Mode

SPI2Mode ( Mode [, SPIClockMode])

SPI2Transfer

SPI2Transfer tx, rx

SPIMode

SPIMode ( Mode [, SPIClockMode])

SPITransfer

SPITransfer tx, rx

I2C Software

Command Summary

I2C Overview

These software routines allow GCBASIC programs to send and receive I2C

I2CAckpoll

I2CAckpoll ( I2C_device_address )

I2CAckPollState

<test condition> I2CAckPollState

I2CReceive

I2CReceive data

I2CReset

I2CReset

I2CRestart

I2CRestart

I2CSend

I2CSend data

I2CStart

I2CStart

I2CStartoccurred

I2CStartoccurred

I2CStop

I2CStop

I2C/TWI Hardware Module

Command Summary

HI2C Overview

These methods allow GCBASIC programs to send and receive Inter- Integrated Circuit (I2C™) messages via:

HI2CAckPollState

<test condition[s]> HI2CAckPollState

HI2CMode

HI2CMode Master | Slave

HI2CReceive

HI2CReceive data

HI2CRestart

HI2CRestart

HI2CSetAddress

HI2CSetAddress address_number

HI2CStart

HI2CStart

HI2CStartOccurred

HI2CStartOccurred

HI2CStop

HI2CStop

HI2CStopped

HI2CStopped

HI2CWaitMSSP

HI2CWaitMSSP

Sound

Command Summary

Play

Play SoundPlayDataString

Play RTTTL

PlayRTTTL SoundPlayRTTTLDataString

ShortTone

ShortTone Frequency, Duration

Sound Overview

These GCBASIC methods generate tones of a given frequency and duration.

Tone

Tone Frequency, Duration

Timers

Command Summary

ClearTimer

ClearTimer TimerNo

InitTimer0

InitTimer0 source, prescaler

InitTimer1

InitTimer1 source, prescaler

InitTimer10

InitTimer10 prescaler, postscaler

InitTimer12

InitTimer12 prescaler, postscaler

InitTimer2

InitTimer2 prescaler, postscaler

InitTimer3

InitTimer3 source, prescaler

InitTimer4

InitTimer4 prescaler, postscaler

InitTimer5

InitTimer5 source, prescaler

InitTimer6

InitTimer6 prescaler, postscaler

InitTimer7

InitTimer7 source, prescaler

InitTimer8

InitTimer8 prescaler, postscaler

Reading Timers

GCBASIC has the following macros to read a specific timer value. They

Settimer

Settimer timernumber, byte_value

SMT Timers

The Signal Measurement Timer (SMT) capability is a 24-bit counter with advanced clocking and gating logic, which can be configured for me…​

StartTimer

StartTimer TimerNo

StopTimer

StopTimer TimerNo

Timer Overview

GCBASIC supports methods to set, clear, read, start and stop the microcontroller timers.

Variables Operations

Command Summary

Alloc

Alloc creates a special type of variable - an array variant. This array variant can store values. The values stored in this array variant…​

BcdToDec_GCB

BcdToDec_GCB ( ByteVariable )

DecToBcd_GCB

DectoBcd( ByteVariable )

Dim

Dim variable // will define a Byte variable

More on setting Variables and Constants

Within GCBASIC you can use regular variable assignments. But, you can also use C like maths assignments.

Rotate

Rotate variable {Left | Right} [Simple]

Set

Set variable.bit {On | Off}

Setting Variables


SWAP

SWAP( VariableA, VariableB)

SWAP4

SWAP4( VariableA)

Using Variables

Using and accessing bytes within word and long numbers etc may be required when you are creating your solution. This can be done with som…​

Variable Lifecycle

Within GCBASIC you can use variables. This section details the Variable Lifecycle when using variables.

Peek

OutputVariable = Peek (location)

Poke

Poke(location, value)

String Manipulation

Command Summary

Asc

bytevar= ASC(string, [position] )

ByteToBin

stringvar = ByteToBin(bytevar)

ByteToHex

stringvar = ByteToHex(number)

ByteToString

stringvar = ByteToString(byte_variable) 'supports byte.

Chr

stringvar = CHR(bytevar)

Concatenation

stringvar = variable1 + variable2

Fill

stringvar = Fill ( byte_value_of_the_new_length , pad_character )

Instr

location = Instr(source, find)

IntegerToBin

stringvar = IntegerToBin(integervar)

IntegerToHex

stringvar = IntegerToHex(number)

IntegerToString

stringvar = IntegerToString(Integer_variable) 'supports Integer.

LCase

output = LCase(source)

Left

output = Left(source, count)

LeftPad

LeftPad(string_variable,byte_value_of_the_new_length,pad_character)

Len

output= Len( string )

LongToBin

stringvar = LongToBin(longvar)

LongToHex

stringvar = LongToHex(number)

LongToString

stringvar = LongToString(Long_variable) 'supports Long.

Ltrim

stringvar = LTRIM(stringvar)

Mid

output = Mid(source, start[, count])

Pad

out_string = Pad( string_variable, byte_value_of_the_new_length, pad_character)

Right

output = Right(source, count)

Rtrim

stringvar = Rtrim(stringvar)

SingleToBin

stringvar = SingleToBin(Singlevar)

SingleToHex

stringvar = SingleToHex(number)

SingleToString

stringvar = SingleToString(Single_variable) 'supports Single.

StringToByte

var = StringToByte(string) 'Supports decimal byte range strings only.

StringToLong

var = StringToLong(string) 'Supports decimal Long range strings only.

StringToSingle

var = StringToSingle(string) 'Supports decimal Single range strings only.

StringToWord

var = StringToWord(string) 'Supports decimal Word range strings only.

Trim

stringvar = Trim(stringvar)

UCase

output = UCase(source)

ULongIntToBin

stringvar = ULongIntToBin(ULongIntvar)

WordToBin

stringvar = WordToBin(bytevar)

WordToHex

stringvar = WordToHex(number)

WordToString

stringvar = WordToString(Word_variable) 'supports Word.

Deprecated string functions.

Command Summary

Hex

stringvar = Hex(number)

Str

stringvar = Str(number) 'supports decimal byte and word strings only.

Val

var = Val(string) 'Supports decimal byte and word strings only.

Miscellaneous Commands

Command Summary

GetUserID

Available on all Microchip microcontrollers that support UserIDs.

Maths

Command Summary

Abs

integer_variable = Abs( integer_variable )

Average

integer_variable = Average(byte_variable1 , byte_variable2)

Difference

Difference ( word_variable1 , word_variable2 ) or

Int

integer_variable = Int( single_variable )

Log10

returned_word_variable = Log10 (word_value)

Log2

returned_word_variable = Log2 ( word_value )

Logarithms

GCBASIC support logarithmic functions through the include file <maths.h>.

Loge

returned_word_variable = Loge ( word_value )

Power

power( base, exponent )

RoundSingle

rounded_single_value = RoundSingle( single_variable )

Scale

integer_variable = Scale (value_word , fromLow_integer , fromHigh_integer , toLow_integer , toHigh_integer [, calibration_integer] )

Sqrt

word_variable = sqrt ( word )

Trigonometry ATAN

GCBASIC supports the trigonometric function for ATan.

Trigonometry Sine, Cosine and Tangent

GCBASIC supports Three Primary Trigonometric Functions

Port control

Command Summary

Dir

Dir port.bit {In | Out} (Individual Form)

Weak Pullups

Weak pullups provide a method within many microcontrollers such as the Atmel AVR and Microchip PIC microcontrollers to support internal/s…​

Peripheral Pin Select for Microchip microcontrollers.

Peripheral Pin Select (PPS) enables the digital peripheral I/O pins to be changed to support mapping of external pins to different pins.

UnLockPPS

UNLOCKPPS

LockPPS

LOCKPSS