Today’s post describes my adventure into the world of TI (Texas Instruments) programming. A little bit out of its time but nevertheless interesting to anyone who likes to learn new things and open their horizons.
My cousin is a few months away of completing his Civil engineering degree and is really interested in TI programming, doing scripts that help him solve problems really fast instead of having to do them manually (most useful in exams). He does all the programming in TI-Basic, a language similar to Basic but specific to TI calculators and like most (if not all) of these interpreted languages, they don’t provide any security if you want to sell your programs. Thus he turned to C programming. Now, C is a whole new beast when compared with this TI-Basic language and it’s much harder to start doing some interesting things without your programs crashing all over the place.
He asked me for help but having no knowledge of this TI-Basic or C tools/libraries/APIs available for these calculators and without access to internet and limited documentation and samples I wasn’t able to get complete the program although I did manage to make half of it. This was a 4 hour marathon that started around 22h30 till 2h30 and I had to admit defeat at the time since I was very tired but I promised to help him to finish the program. I don’t have a TI calculator so I needed to find a way to test it in my PC and fortunately there is an IDE along with an emulator and ROM image available for free on the internet. I’ll list what’s needed to be able to run and the debug C programs for TI calculators because it took me a while to get everything up and running due to incompatible versions of software.
- Download and install TIGCC 0.96 beta 8 (Unofficial version)
- Download and install TiEmu 3.02a
- Download TI Voyage 200 ROM image (my cousin’s model)
- Create a project in TIGCC
- Run the project (Debug –> Run)
- When the TiEmu wizard appears select “You have downloaded a FLASH upgrade on the TI website”
- Then select the TI Voyage 200 ROM image you’ve downloaded before.
Voilà! If everything went well you should see the program running on the emulator.
If you want to debug your project, follow these steps:
- Project –> Options
- Select the “Compilation” tab and then the option “Generate debug information”
- Run the project (Debug –> Run)
You should see new windows open if you followed these steps. These are the debug windows that will help you find your bugs.
Here are a few snippets I had to discover here and there through samples / documentation:
/* Retrieves strings passed into the program */
while ((argtype = GetArgType (argptr)) != END_TAG)
if (argtype == STR_TAG)
str = GetStrnArg(argptr);
/* Get a variable from TI-Basic into C */
SYM_ENTRY *sym_entry = SymFindPtr (SYMSTR ("variableName"), 0);
ESI expr = HToESI(sym_entry->handle);
int argType = GetArgType(expr); /* Retrieves the type of the expression */
long num = GetIntArg(expr); /* Retrieves an integer if the expression holds an integer (positive or negative) */
/* Directly from TIGCC documentation: Run a TI-Basic program or statement from C */
strcpy (fname, name);
strcat (fname, "()");
h = HS_popEStack ();
NG_execute (h, FALSE);
Including tigcclib.h will make sure that you have all the TI library functions available in C. For the last snippet you need to follow these steps if you have an error regarding push_parse_text function:
- go to Project->Options
- select the “Compilation” tab
- click on “Program Options…”
- select the “Operating System” tab
- and set the “Minimum AMS Version” as 1.01