Original printed contents
Table of Contents.
Positron16 Compiler Overview ................................................................................ 18 Identifiers.....................................................................................................................19 Line Labels ...................................................................................................................19 Commenting Lines of Code.............................................................................................20 Ports and other SFRs .....................................................................................................21 PPS_Input (pPin, pFunction) ................................................................................................................. 21 PPS_Output(pPin, pFunction)................................................................................................................ 22 PPS_Lock().......................................................................................................................................... 22 PPS_UnLock()...................................................................................................................................... 22 Numeric Representations ...............................................................................................23 Quoted String of Characters ...........................................................................................23 Standard Variables ........................................................................................................24 Static Variables .............................................................................................................27 Global Variables ............................................................................................................29 Shared Variables ...........................................................................................................30 Pin Variables.................................................................................................................31 32-bit and 64-bit FloatIng Point Maths ............................................................................32 FloatIng Point To Integer Rounding....................................................................................................... 35 FloatIng Point Exception Flags .............................................................................................................. 36 Aliases..........................................................................................................................37 Finer points of variable handling............................................................................................................ 39 Symbols .......................................................................................................................42 Creating and using Arrays ..............................................................................................43 Finer points of array variables. .............................................................................................................. 48 Creating and using String variables .................................................................................49 Procedures ...................................................................................................................56 Parameters.......................................................................................................................................... 56 Parameter as an Alias to a Global Variable or SFR................................................................................... 57 Local Variable and Label Names ............................................................................................................ 57 Procedure Return Variable .................................................................................................................... 58 Return Variable as an Alias to an SFR or Global Variable.......................................................................... 60 A Typical Procedural BASIC Program Layout ....................................................................62 A Typical Flat BASIC Program Layout ..............................................................................63 General Format .............................................................................................................64 Line Continuation Character '_' .......................................................................................64 Creating and using Flash Memory Tables.........................................................................65 String Comparisons .......................................................................................................68 Relational Operators......................................................................................................71 Boolean Logic Operators ................................................................................................72
Mathematic Operations and Functions .................................................................... 73 Abs ............................................................................................................................. 89 fAbs ............................................................................................................................ 90 dAbs ........................................................................................................................... 91 Acos............................................................................................................................ 92 dAcos.......................................................................................................................... 93 Asin............................................................................................................................. 94 dAsin........................................................................................................................... 95 Atan............................................................................................................................ 96 dAtan .......................................................................................................................... 97 Atan2 .......................................................................................................................... 98 dAtan2 ........................................................................................................................ 99 Ceil ............................................................................................................................100 dCeil...........................................................................................................................101 Cos ............................................................................................................................102 dCos...........................................................................................................................103 Dcd............................................................................................................................104 Dig '?'........................................................................................................................105 Exp ............................................................................................................................106 dExp ..........................................................................................................................107 Floor ..........................................................................................................................108 dFloor.........................................................................................................................109 fRound .......................................................................................................................110 dRound ......................................................................................................................111 ISin............................................................................................................................112 ICos ...........................................................................................................................113 Isqr............................................................................................................................114 Log ............................................................................................................................115 dLog...........................................................................................................................116 Log10.........................................................................................................................117 dLog10.......................................................................................................................118 Modf ..........................................................................................................................119 Modd..........................................................................................................................120 Ncd ............................................................................................................................121 Pow............................................................................................................................122
dPow..........................................................................................................................123 Rev '@'.......................................................................................................................124 Sin .............................................................................................................................125 dSin ...........................................................................................................................126 Sqr.............................................................................................................................127 dSqr...........................................................................................................................128 Tan ............................................................................................................................129 dTan ..........................................................................................................................130
Peripheral and Interfacing Commands.................................................................. 135 ADin...........................................................................................................................136 Bstart .........................................................................................................................138 Bstop .........................................................................................................................139 Brestart ......................................................................................................................139 BusAck .......................................................................................................................139 BusNack .....................................................................................................................139 Busin..........................................................................................................................140 Busout........................................................................................................................143 Button........................................................................................................................147 PinClear......................................................................................................................149 Counter ......................................................................................................................151 DTMFout ....................................................................................................................152 Freqout ......................................................................................................................153 HbStart.......................................................................................................................155 HbStop.......................................................................................................................156 HbRestart ...................................................................................................................156 HbusAck .....................................................................................................................156 HbusNack ...................................................................................................................156 Hbusin........................................................................................................................157 Hbusout......................................................................................................................160 HbStart2.....................................................................................................................163 HbStop2 .....................................................................................................................164 HbRestart2 .................................................................................................................164 HbusAck2 ...................................................................................................................164 HbusNack2 .................................................................................................................164 Hbusin2......................................................................................................................165 Hbusout2....................................................................................................................168 High (PinHigh) ............................................................................................................172 HPWM ........................................................................................................................174 I2Cin..........................................................................................................................175 I2Cout........................................................................................................................177 Inkey .........................................................................................................................180 Input (PinInput) ..........................................................................................................181 Low (PinLow)..............................................................................................................183
Output (PinOutput)......................................................................................................185 Oread.........................................................................................................................187 Owrite........................................................................................................................191 PinGet (GetPin) ...........................................................................................................193 PinMode .....................................................................................................................194 Pot.............................................................................................................................196 PulseIn.......................................................................................................................197 PulseOut.....................................................................................................................198 PWM ..........................................................................................................................199 RCin...........................................................................................................................200 Servo .........................................................................................................................202 PinSet ........................................................................................................................204 Shin ...........................................................................................................................206 Shout .........................................................................................................................208 Sound ........................................................................................................................210 Toggle........................................................................................................................211
Async Serial Commands......................................................................................... 212 Hrsin, Hrsin2, Hrsin3, Hrsin4 ........................................................................................213 Hrsout, Hrsout2, Hrsout3, Hrsout4................................................................................221 HrsoutLn, Hrsout2Ln, Hrsout3Ln, Hrsout4Ln ..................................................................227 Hserin, Hserin2, Hserin3, Hserin4 .................................................................................228 Hserout, Hserout2, Hserout3, Hserout4.........................................................................233 HseroutLn, Hserout2Ln, Hserout3Ln, Hserout4Ln ...........................................................237 HSerialx_ChangeBaud..................................................................................................238 Rsin ...........................................................................................................................239 Rsout .........................................................................................................................244 RsoutLn......................................................................................................................249
LCD Commands ......................................................................................................250 Box ............................................................................................................................251 Circle..........................................................................................................................254 Cls .............................................................................................................................257 Cursor ........................................................................................................................259 LCDread .....................................................................................................................261 LCDwrite ....................................................................................................................263 Line............................................................................................................................266 LineTo........................................................................................................................269 Pixel...........................................................................................................................270 Plot ............................................................................................................................271 Print...........................................................................................................................274 Using a KS0108 Graphic LCD............................................................................................................... 280 Using a Toshiba T6963 Graphic LCD .................................................................................................... 283 Using an ILI9320 320x240 pixel Colour Graphic LCD ............................................................................. 286 Touch_Active ..............................................................................................................290 Touch_Read................................................................................................................292 Touch_HotSpot ...........................................................................................................294 Toshiba_Command......................................................................................................296 Toshiba_UDG..............................................................................................................299 UnPlot ........................................................................................................................301
Comparison and Loop Commands.......................................................................... 302 Branch........................................................................................................................303 BranchL......................................................................................................................305 Break .........................................................................................................................306 Bound ........................................................................................................................308 Continue.....................................................................................................................309 Do...Loop....................................................................................................................310 For...Next...Step..........................................................................................................312 If..Then..ElseIf..Else..EndIf ..........................................................................................314 On GoTo.....................................................................................................................316 On Gosub ...................................................................................................................318 Repeat...Until..............................................................................................................320 Select..Case..EndSelect................................................................................................321 SizeOf ........................................................................................................................323 Tern...........................................................................................................................324 While...Wend ..............................................................................................................325
General BASIC Commands .....................................................................................326 AddressOf...................................................................................................................327 Call ............................................................................................................................328 Clear ..........................................................................................................................329 ClearBit ......................................................................................................................330 Dec ............................................................................................................................331 DelayCs......................................................................................................................332 DelayMs .....................................................................................................................333 DelayUs......................................................................................................................334 Dig.............................................................................................................................335 GetBit.........................................................................................................................336 Gosub ........................................................................................................................337 GoTo..........................................................................................................................338 Inc.............................................................................................................................339 LoadBit.......................................................................................................................340 Pop ............................................................................................................................341 Ptr8, Ptr16, Ptr32, Ptr64...............................................................................................343 Push...........................................................................................................................346 Random......................................................................................................................350 Return........................................................................................................................351 Rol.............................................................................................................................352 Ror ............................................................................................................................354 Seed ..........................................................................................................................356 SetBit .........................................................................................................................357 Set.............................................................................................................................358 Sleep..........................................................................................................................359 Stop...........................................................................................................................360 Swap..........................................................................................................................361
RAM String Variable Commands ............................................................................ 362 Len ............................................................................................................................363 Left$ ..........................................................................................................................365 Mid$...........................................................................................................................367 Right$ ........................................................................................................................369 Strn............................................................................................................................371 Str$............................................................................................................................372 ToLower .....................................................................................................................374 ToUpper .....................................................................................................................376 Val .............................................................................................................................378
Flash Memory and EEPROM Commands................................................................. 380 Cdata .........................................................................................................................381 cPtr8, cPtr16, cPtr24, cPtr32, cPtr64 .............................................................................384 Cread8, Cread16, Cread24, Cread32, Cread64 ...............................................................387 Edata .........................................................................................................................390 Eread .........................................................................................................................395 Ewrite ........................................................................................................................396 LookDown ..................................................................................................................397 LookDownL.................................................................................................................398 LookUp.......................................................................................................................399 LookUpL .....................................................................................................................400 Creating Flash Memory Tables using Dim as Code or Dim as Flash ..................................401
Compiler Directives................................................................................................ 404 Asm..EndAsm..............................................................................................................405 Config ........................................................................................................................406 Declare.......................................................................................................................411 Misc Declares. ................................................................................................................................... 411 ADin Declares.................................................................................................................................... 412 Busin - Busout Declares...................................................................................................................... 413 Hbusin - Hbusout Declares.................................................................................................................. 413 Hbusin2 – Hbusout2 Declares. ............................................................................................................ 414 USART1 Declares for Hserin, Hserout, Hrsin and Hrsout. ....................................................................... 415 USART2 Declares for use with Hrsin2, Hserin2, Hrsout2 and Hserout2.................................................... 416 USART3 Declares for use with Hrsin3, Hserin3, Hrsout3 and Hserout3.................................................... 417 USART4 Declares for use with Hrsin4, Hserin4, Hrsout4 and Hserout4.................................................... 418 HPWM Declares. ................................................................................................................................ 418 Alphanumeric (Hitachi HD44780) LCD Print Declares............................................................................. 419 Graphic LCD Declares......................................................................................................................... 421 KS0108 Graphic LCD specific Declares. ................................................................................................ 421 Toshiba T6963C Graphic LCD specific Declares. .................................................................................... 422 ILI9320 Colour Graphic LCD specific Declares....................................................................................... 424 ADS7846 Touch Screen controller Declares. ......................................................................................... 425 Keypad Declare.................................................................................................................................. 425 Rsin - Rsout Declares. ........................................................................................................................ 425 Serin - Serout Declare. ....................................................................................................................... 427 Shin - Shout Declare. ......................................................................................................................... 428 Stack Declares................................................................................................................................... 428 Oscillator Frequency Declare............................................................................................................... 429 Device........................................................................................................................433 Dim............................................................................................................................434 Creating Flash Memory Tables using Dim ............................................................................................. 439 Creating variables in Y RAM ................................................................................................................ 442 Creating variables in DMA RAM ........................................................................................................... 443 End ............................................................................................................................445 Include.......................................................................................................................446 Using Include files to tidy up your code................................................................................................ 446 Installed Include files ......................................................................................................................... 447 Proc-EndProc ..............................................................................................................450 Parameters........................................................................................................................................ 450 Local Variable and Label Names .......................................................................................................... 451 Return Variable.................................................................................................................................. 451 Sub-EndSub................................................................................................................455 Symbol.......................................................................................................................456
Interrupt Directives ...............................................................................................457 Isr, EndIsr ..................................................................................................................458
Using the Preprocessor ..........................................................................................462 Preprocessor Directives................................................................................................463 Conditional Directives ($ifdef, $ifndef, $if, $endif, $else and $elseif)................................466 SFR bit access using the preprocessor’s built-in meta macros..........................................468
Positron16 IDE Overview....................................................................................... 470 Menu Bar....................................................................................................................472 Main Toolbar...............................................................................................................473 Edit Toolbar ................................................................................................................474 Code Explorer .............................................................................................................476 Results View ...............................................................................................................477 Editor Options.............................................................................................................479 Highlighter Options......................................................................................................481 Compile and Program Options ......................................................................................483 Installing a Programmer...............................................................................................484 Creating a custom Programmer Entry............................................................................485 IDE Plugins.................................................................................................................487 ASCII Table ................................................................................................................488 Hex View ....................................................................................................................488 Assembler Window ......................................................................................................489 Assembler Main Toolbar...............................................................................................490 Assembler Editor Options .............................................................................................491 Serial Communicator....................................................................................................492 Serial Communicator Main Toolbar................................................................................493
Protected Positron16 Compiler Words................................................................... 497













