Analog/Digital conversion
| Command | Summary |
|---|---|
|
ADFormat ( Format_Left | Format_Right ) |
|
|
This command is obsolete. There should be no need to call it. GCBASIC |
|
|
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 … |
|
|
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 … |
|
|
For a normal ( also called a Single Channel ) read use. |
|
|
For a normal ( also called a Single Channel ) read use. |
|
|
For a normal ( also called a Single Channel ) read use. |
|
|
Pot pin, output |
Bitwise
| Command | Summary |
|---|---|
|
GCBASIC (as with most other microcontroller programming languages) supports bitwise operations. |
|
|
BitsOut = FnLSL(BitsIn, NumBits) |
|
|
BitsOut = FnLSR(BitsIn, NumBits) |
|
|
SetWith(TargetBit, Source) |
MCU EEPROM ( DFM )
| Command | Summary |
|---|---|
|
EEPROM DataSetName [[,]address] |
|
|
EPRead location, store |
|
|
EPWrite location, data |
HEFM ( PFM )
| Command | Summary |
|---|---|
|
HEFEraseBlock ( block_number ) |
|
|
Some enhanced mid-range Microchip PIC devices support High-Endurance Flash (HEF) memory. These devices lack the data EEPROM found on othe… |
|
|
'as a subroutine |
|
|
HEFReadBlock ( block_number, buffer(), [, num_bytes] ) |
|
|
'as a subroutine |
|
|
HEFWrite ( location, data ) |
|
|
HEFWriteBlock ( block_number, buffer(), [, num_bytes] ) |
|
|
HEFWriteWord ( location, data_word_value ) |
PROGMEM ( PFM )
| Command | Summary |
|---|---|
|
DATA DataSetName [as Byte | Word] |
|
|
PFMRead (location, store) |
|
|
PFMWrite (location, value) |
|
|
ProgramErase (location) |
|
|
ProgramRead (location, store) |
|
|
ProgramWrite (location, value) |
PROGMEM ( MCU Configuration )
| Command | Summary |
|---|---|
|
deviceconfigurationRead (location, store) |
SAFM
| Command | Summary |
|---|---|
|
SAFEraseBlock ( block_number ) |
|
|
Some Advanced (18F) and some Enhanced Mid-Range (16F) Microchip PIC devices support Storage Area Flash (SAF) memory. These devices also i… |
|
|
'as a subroutine |
|
|
SAFReadBlock ( block_number, buffer(), [, num_bytes] ) |
|
|
'as a subroutine |
|
|
SAFWrite ( location, data ) |
|
|
SAFWriteBlock ( block_number, buffer(), [, num_bytes] ) |
|
|
SAFWriteWord ( location, data_word_value ) |
EERAM ( Device )
| Command | Summary |
|---|---|
|
This section covers the 47xxx EERam devices. |
SRAM ( Device )
| Command | Summary |
|---|---|
|
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 location, store |
|
|
SRAMWrite location, data |
Flow control
| Command | Summary |
|---|---|
|
Do [{While | Until} condition] |
|
|
End |
|
|
Exit Sub | Exit Function | Exit Do | Exit For | Exit Repeat |
|
|
For counter = start To end [Step increment] |
|
|
Gosub label |
|
|
Goto label |
|
|
If condition Then command |
|
|
IndCall Address |
|
|
Pause time_ms |
|
|
Repeat times |
|
|
Select Case var |
|
|
Wait time units |
Fixed Voltage Reference
| Command | Summary |
|---|---|
|
FVRInitialize ( FVR_OFF | FVR_1x | FVR_2x | FVR_4x ) |
|
|
user_var = FVRIsOutputReady() |
Interrupts
| Command | Summary |
|---|---|
|
Interrupts are a feature of many microcontrollers. They allow the |
|
|
IntOff |
|
|
IntOn |
|
|
On Interrupt event Call handler |
|
|
GCBASIC supports a default interrupt handler in two modes: |
Keypad
| Command | Summary |
|---|---|
|
The keypad routines allow for a program to read from a 4 x 4 matrix |
|
|
var = KeypadData |
|
|
largevar = KeypadRaw |
Graphical LCD
| Command | Summary |
|---|---|
|
Box(LineX1,LineY1, LineX2, LineY2 [, LineColour ] ) |
|
|
Circle(XPixelPosition, YPixelPosition, Radius [ [,Optional LineColour] [,Optional Rounding] ] ) |
|
|
Ellipse(XPixelPosition, YPixelPosition, XRadius, YRadius [,Optional LineColour] ) |
|
|
This section covers GLCD devices known as e-Papers. |
|
|
FilledBox(LineX1,LineY1, LineX2, LineY2, Optional LineColour = 1) |
|
|
FilledCircle(XPixelPosition, YPixelPosition, Radius [,Optional LineColour] ) |
|
|
FilledEllipse(XPixelPosition, YPixelPosition, XRadius, YRadius [,Optional LineColour] ) |
|
|
FilledTriangle( XPixelPosition1, YPixelPosition1, XPixelPosition2, YPixelPosition2, XPixelPosition3, YPixelPosition3 [,Optional LineColou… |
|
|
This section covers GLCD fonts and characters. |
|
|
The GLCD commands are used to control a Graphical Liquid Crystal Display (GLCD) |
|
|
GLCDCLS [GLCDBackground] |
|
|
GLCDDisplay Off | On |
|
|
GLCDDrawChar(CharLocX, CharLocY, CharCode [, Optional Colour] ) |
|
|
GLCDDrawString(CharLocX, CharLocY, String [, Optional Colour] ) |
|
|
GLCDLocateString(PrintLocX, PrintLocY ) |
|
|
GLCDPrint(PrintLocX, PrintLocY, PrintData_Byte [, Optional Colour] ) ',or |
|
|
GLCDPrintLargeFont( PrintLocX, PrintLocY, PrintData_String [, Optional Colour] ) |
|
|
GLCDPrintString( String ) |
|
|
GLCDPrintStringLn( String ) |
|
|
GLCDPrintWithSize(PrintLocX, PrintLocY, PrintData_Byte , FontSize [, Color ] ) ',or |
|
|
byte_variable = GLCDReadByte |
|
|
GLCDROTATE LANDSCOPE | PORTRAIT_REV | LANDSCAPE_REV | PORTRAIT |
|
|
GLCDTime |
|
|
GLCD_Open_PageTransaction |
|
|
GLCDWriteByte (LCDByte) |
|
|
This section covers GLCD devices that use the HX8347G graphics controller. |
|
|
Hyperbole (x, y, a_axis, b_axis, type, ModeStop, optional LineColour=GLCDForeground) |
|
|
This section covers GLCD devices that use the ILI9326 graphics controller. The ILI9326 is a TFT LCD Single Chip Driver with 400RGBx320 Re… |
|
|
This section covers GLCD devices that use the ILI9340 graphics controller. The ILI9340 is a TFT LCD Single Chip Driver with 240RGBx320 Re… |
|
|
This section covers GLCD devices that use the ILI9341 graphics controller. The ILI9341 is a TFT LCD Single Chip Driver with 240RGBx320 Re… |
|
|
This section covers GLCD devices that use the ILI9481 graphics controller. |
|
|
This section covers GLCD devices that use the ILI9486(L) graphics controller. |
|
|
This section covers GLCD devices that use the ILI9488 graphics controller. |
|
|
This section covers GLCD devices that use the KS0108 graphics controller. |
|
|
Line(LineX1,LineY1, LineX2, LineY2, Optional LineColour = 1) |
|
|
This section covers GLCD devices that use the serially attached Nextion graphics displays. |
|
|
This section covers GLCD devices that use the NT7108C graphics controller. |
|
|
Parabola (x, y, p_factor, type, modestop, optional LineColour=GLCDForeground) |
|
|
This section covers GLCD devices that use the PCD844 graphics controller. |
|
|
PSet(XPosition, YPosition, GLCDState) |
|
|
This section covers GLCD devices that use the SDD1289 graphics controller. The SDD1289 is a 240 x 320 single chip controller driver IC fo… |
|
|
This section covers GLCD devices that use the SH1106 graphics controller. THe SH1106 is a single-chip CMOS OLED/PLED driver with controll… |
|
|
This section covers GLCD devices that use the SSD1306 graphics controller. |
|
|
This section covers GLCD devices that use the SSD1331 graphics controller. The SSD1331 is a single-chip controller/driver for 262K-color,… |
|
|
This section covers GLCD devices that use the SSD1351 graphics controller. The SSD1351 is a single-chip controller/driver for 262K-color,… |
|
|
This section covers GLCD devices that use the ST7567 graphics controller. |
|
|
This section covers GLCD devices that use the ST7735 graphics controller. The ST7735 or ST7735R is a single-chip controller/driver for 26… |
|
|
This section covers GLCD devices that use the ST7789 graphics controller. The ST7789 is a TFT LCD Single Chip Driver with 240x240 or 320x… |
|
|
This section covers GLCD devices that use the ST7920 graphics controller. |
|
|
This section covers Graphical Liquid Crystal Display (GLCD) devices that use the Toshiba T6963 graphics controller. The T6963 is a monoch… |
|
|
Triangle(XPixelPosition1, YPixelPosition1, XPixelPosition2, YPixelPosition2, XPixelPosition3, YPixelPosition3 [,Optional LineColour] ) |
|
|
This section covers GLCD devices that use the UC1601 graphics controller. |
Touch Screen
| Command | Summary |
|---|---|
|
ADS7843_Init |
Liquid Crystal Display
| Command | Summary |
|---|---|
|
CLS |
|
|
var = Get(Line, Column) |
|
|
The LCD routines in this section allow GCBASIC programs to control an |
|
|
LCDBacklight ( On | Off ) |
|
|
LCDCMD value |
|
|
LCDCreateChar char, chardata() |
|
|
LCDCreateGraph value |
|
|
LCDCursor value |
|
|
LCDDisplayOff |
|
|
LCDDisplayOn |
|
|
LCDHex value |
|
|
LCDHome |
|
|
LCDSpace value |
|
|
LCDWriteChar char |
|
|
Locate Line, Column |
|
|
Print string |
|
|
Put Line, Column, Character |
Pulse width modulation
| Command | Summary |
|---|---|
|
The methods described in this section allow the generation of Pulse |
|
|
For compatibility all channels are supported by default. This is maintains backward compatibility. |
|
|
HPWM channel, frequency, duty cycle, timer [, resolution] |
|
|
HPWM16 channel, frequency, duty cycle 'Enable a 16-bit PWM channel' |
|
|
HPWM channel, frequency, duty cycle |
|
|
HPWM channel, frequency, duty cycle |
|
|
PWMOn 'only applies to CCP/PWM channel 1 |
|
|
PWMOn |
|
|
HPWM_CCPTimerN channel, frequency, duty cycle [, timer 2, 4 or 6 ] |
|
|
HPWMOff ( channel ) 'selectively turn off the CCP channel |
|
|
HPWMOff ( channel, PWMHardware ) |
|
|
HPWMOff ( channel ) 'selectively turn off the CCP channel |
|
|
HPWMUpdate ( channel, duty_cycle ) |
|
|
HPWMUpdate ( channel, duty_cycle ) |
|
|
The methods described in this section allow the generation of Pulse |
|
|
PWMOut channel, duty cycle, cycles |
|
|
PWMOff |
|
|
PWMOff |
|
|
PWMOn |
|
|
PWMOn |
|
|
PWMOut channel, duty cycle, cycles |
|
|
PulseOut pin, time units |
|
|
PulseOutInv pin, time units |
|
|
PulseIn pin, user_variable, time units |
|
|
PulseInInv pin, user_variable, time units |
Random Numbers
| Command | Summary |
|---|---|
|
These routines allow GCBASIC to generate pseudo-random numbers. |
|
|
var = Random |
|
|
Randomize |
7-Segment Displays
| Command | Summary |
|---|---|
|
The GCBASIC 7 segment display methods make it easier for GCBASIC programs to display numbers and letters on 7 segment LED displays. |
|
|
The TM1637 disaplay module is used for displaying numbers on a keyboard matrix. |
|
|
The TM1637 display module is used for displaying numbers on a keyboard matrix. |
|
|
The 7 Segment Displays module provide a cheap red, green, blue or white bright LED Display. |
|
|
This is a Common Anode 7 Segment display example. |
|
|
This is a Common Cathode 7 Segment display example. |
|
|
DisplayChar (display, character, dot) |
|
|
DisplayValue (display, data) |
|
|
DisplayValue (display, data, dot) |
|
|
TM_Bright = Brightness |
|
|
TM_Bright = Brightness |
|
|
TM_Point = (Point) |
|
|
TMDec Value [, Options ] |
|
|
TMDec Value [, Options ] |
|
|
TMHex Value |
|
|
TMHex Value |
|
|
TMWrite4Dig (dig1, dig2, dig3, dig4 [, Brightness ], Colon ] ] ) |
|
|
TMWrite6Dig (dig1, dig2, dig3, dig4, dig5, dig6, Brightness, Point) |
|
|
TMWriteChar ( TMaddr, TMchar ) |
|
|
TMWriteChar ( TMaddr, TMchar ) |
One Wire Devices
| Command | Summary |
|---|---|
|
The DS18B20 is a 1-Wire digital temperature sensor from Maxim IC. |
|
|
For Single Channel/Device only. The method assumes a single DS18B20 device on the OneWire bus. |
|
|
ReadDigitalTemp |
|
|
byte_var = ReadTemp |
|
|
byte_var = ReadTemp12 |
Serial Communications
| Command | Summary |
|---|---|
|
HSerGetNum myNum ‘Gets a multi digit number from USART 1 |
|
|
HSerGetString myString ‘Get a multi char string from USART 1 |
|
|
HSerPrint user_value [,1|2|3|4] 'Choose comport with optional parameter |
|
|
HserPrintByteCRLF user_data [, 1 | 2 | 3 | 4 ] |
|
|
HserPrintCRLF [optional BYTE] [, 1 | 2 | 3 | 4 ] |
|
|
HSerPrintStringCRLF user_string [,1|2|3|4] 'Choose comport with optional parameter |
|
|
HSerReceive (user_byte_variable) |
|
|
user_byte = HSerReceiveFrom [,1 | 2 | 3 | 4] |
|
|
HSerSend user_byte [,1|2|3|4] 'Choose comport with optional parameter |
|
|
HSerSendBytes(byte1, byte2 [, byte3 … up to byte16]) |
|
|
InitSer channel, rate, start, data, stop, parity, invert |
|
|
GCBASIC support programs to communicate easily using RS232. |
|
|
These routines allow the microcontroller to send and receive RS232 data. |
|
|
These routines allow the microcontroller to send and receive RS232 data. |
|
|
Ser1Print value |
|
|
bytevar = Ser1Receive |
|
|
Ser1Send data |
|
|
SerPrint channel, value |
|
|
SerReceive channel, output |
|
|
SerSend channel, data |
Infrared Remote Control
| Command | Summary |
|---|---|
|
NECSend address, data |
|
|
RC5Send address, data |
PS/2
| Command | Summary |
|---|---|
|
output = InKey |
|
|
These routines make it easier to communicate with a PS/2 device, |
|
|
output = PS2ReadByte |
|
|
PS2SetKBLeds (LedStatus) |
|
|
PS2WriteByte user_data |
SPI
| Command | Summary |
|---|---|
|
FastHWSPI2Transfer tx |
|
|
FastHWSPITransfer tx |
|
|
The SPI interface allows for the transmission and receiption of data simultaneously on two lines (MOSI and MISO). |
|
|
SPI2Mode ( Mode [, SPIClockMode]) |
|
|
SPI2Transfer tx, rx |
|
|
SPIMode ( Mode [, SPIClockMode]) |
|
|
SPITransfer tx, rx |
I2C Software
| Command | Summary |
|---|---|
|
These software routines allow GCBASIC programs to send and receive I2C |
|
|
I2CAckpoll ( I2C_device_address ) |
|
|
<test condition> I2CAckPollState |
|
|
I2CReceive data |
|
|
I2CReset |
|
|
I2CRestart |
|
|
I2CSend data |
|
|
I2CStart |
|
|
I2CStartoccurred |
|
|
I2CStop |
I2C/TWI Hardware Module
| Command | Summary |
|---|---|
|
These methods allow GCBASIC programs to send and receive Inter- Integrated Circuit (I2C™) messages via: |
|
|
<test condition[s]> HI2CAckPollState |
|
|
HI2CMode Master | Slave |
|
|
HI2CReceive data |
|
|
HI2CRestart |
|
|
HI2CSetAddress address_number |
|
|
HI2CStart |
|
|
HI2CStartOccurred |
|
|
HI2CStop |
|
|
HI2CStopped |
|
|
HI2CWaitMSSP |
Sound
| Command | Summary |
|---|---|
|
Play SoundPlayDataString |
|
|
PlayRTTTL SoundPlayRTTTLDataString |
|
|
ShortTone Frequency, Duration |
|
|
These GCBASIC methods generate tones of a given frequency and duration. |
|
|
Tone Frequency, Duration |
Timers
| Command | Summary |
|---|---|
|
ClearTimer TimerNo |
|
|
InitTimer0 source, prescaler |
|
|
InitTimer1 source, prescaler |
|
|
InitTimer10 prescaler, postscaler |
|
|
InitTimer12 prescaler, postscaler |
|
|
InitTimer2 prescaler, postscaler |
|
|
InitTimer3 source, prescaler |
|
|
InitTimer4 prescaler, postscaler |
|
|
InitTimer5 source, prescaler |
|
|
InitTimer6 prescaler, postscaler |
|
|
InitTimer7 source, prescaler |
|
|
InitTimer8 prescaler, postscaler |
|
|
GCBASIC has the following macros to read a specific timer value. They |
|
|
Settimer timernumber, byte_value |
|
|
The Signal Measurement Timer (SMT) capability is a 24-bit counter with advanced clocking and gating logic, which can be configured for me… |
|
|
StartTimer TimerNo |
|
|
StopTimer TimerNo |
|
|
GCBASIC supports methods to set, clear, read, start and stop the microcontroller timers. |
Variables Operations
| Command | Summary |
|---|---|
|
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 ( ByteVariable ) |
|
|
DectoBcd( ByteVariable ) |
|
|
Dim variable // will define a Byte variable |
|
|
Within GCBASIC you can use regular variable assignments. But, you can also use C like maths assignments. |
|
|
Rotate variable {Left | Right} [Simple] |
|
|
Set variable.bit {On | Off} |
|
|
|
|
|
SWAP( VariableA, VariableB) |
|
|
SWAP4( VariableA) |
|
|
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… |
|
|
Within GCBASIC you can use variables. This section details the Variable Lifecycle when using variables. |
|
|
OutputVariable = Peek (location) |
|
|
Poke(location, value) |
String Manipulation
| Command | Summary |
|---|---|
|
bytevar= ASC(string, [position] ) |
|
|
stringvar = ByteToBin(bytevar) |
|
|
stringvar = ByteToHex(number) |
|
|
stringvar = ByteToString(byte_variable) 'supports byte. |
|
|
stringvar = CHR(bytevar) |
|
|
stringvar = variable1 + variable2 |
|
|
stringvar = Fill ( byte_value_of_the_new_length , pad_character ) |
|
|
location = Instr(source, find) |
|
|
stringvar = IntegerToBin(integervar) |
|
|
stringvar = IntegerToHex(number) |
|
|
stringvar = IntegerToString(Integer_variable) 'supports Integer. |
|
|
output = LCase(source) |
|
|
output = Left(source, count) |
|
|
LeftPad(string_variable,byte_value_of_the_new_length,pad_character) |
|
|
output= Len( string ) |
|
|
stringvar = LongToBin(longvar) |
|
|
stringvar = LongToHex(number) |
|
|
stringvar = LongToString(Long_variable) 'supports Long. |
|
|
stringvar = LTRIM(stringvar) |
|
|
output = Mid(source, start[, count]) |
|
|
out_string = Pad( string_variable, byte_value_of_the_new_length, pad_character) |
|
|
output = Right(source, count) |
|
|
stringvar = Rtrim(stringvar) |
|
|
stringvar = SingleToBin(Singlevar) |
|
|
stringvar = SingleToHex(number) |
|
|
stringvar = SingleToString(Single_variable) 'supports Single. |
|
|
var = StringToByte(string) 'Supports decimal byte range strings only. |
|
|
var = StringToLong(string) 'Supports decimal Long range strings only. |
|
|
var = StringToSingle(string) 'Supports decimal Single range strings only. |
|
|
var = StringToWord(string) 'Supports decimal Word range strings only. |
|
|
stringvar = Trim(stringvar) |
|
|
output = UCase(source) |
|
|
stringvar = ULongIntToBin(ULongIntvar) |
|
|
stringvar = WordToBin(bytevar) |
|
|
stringvar = WordToHex(number) |
|
|
stringvar = WordToString(Word_variable) 'supports Word. |
Deprecated string functions.
| Command | Summary |
|---|---|
|
stringvar = Hex(number) |
|
|
stringvar = Str(number) 'supports decimal byte and word strings only. |
|
|
var = Val(string) 'Supports decimal byte and word strings only. |
Miscellaneous Commands
| Command | Summary |
|---|---|
|
Available on all Microchip microcontrollers that support UserIDs. |
Maths
| Command | Summary |
|---|---|
|
integer_variable = Abs( integer_variable ) |
|
|
integer_variable = Average(byte_variable1 , byte_variable2) |
|
|
Difference ( word_variable1 , word_variable2 ) or |
|
|
integer_variable = Int( single_variable ) |
|
|
returned_word_variable = Log10 (word_value) |
|
|
returned_word_variable = Log2 ( word_value ) |
|
|
GCBASIC support logarithmic functions through the include file <maths.h>. |
|
|
returned_word_variable = Loge ( word_value ) |
|
|
power( base, exponent ) |
|
|
rounded_single_value = RoundSingle( single_variable ) |
|
|
integer_variable = Scale (value_word , fromLow_integer , fromHigh_integer , toLow_integer , toHigh_integer [, calibration_integer] ) |
|
|
word_variable = sqrt ( word ) |
|
|
GCBASIC supports the trigonometric function for ATan. |
|
|
GCBASIC supports Three Primary Trigonometric Functions |
Port control
| Command | Summary |
|---|---|
|
Dir port.bit {In | Out} (Individual Form) |
|
|
Weak pullups provide a method within many microcontrollers such as the Atmel AVR and Microchip PIC microcontrollers to support internal/s… |
|
|
Peripheral Pin Select (PPS) enables the digital peripheral I/O pins to be changed to support mapping of external pins to different pins. |
|
|
UNLOCKPPS |
|
|
LOCKPSS |

