PIC32 User Interface

User Interface

The user interface is all carried out through a COM port using UART 2 on the PIC. This can run up to 2,000,000 Baud and a specially produced terminal (BV-COM) is available free that can work at these rates. It also has facilities for resetting the BV513 and Xmodem file transfer.

new
error()
sys
dump
list
run
chain
 

Keywords associated with the interface and general use.

new
new

Resets the program area, clears all of the variables and prepares the program space to start again.

error()
a=error()

Syntax errors are displayed on the console at the time the program discovers them. When this kind of error occurs program execution stops. There is another kind of error that will not halt execution or indicate to the console. These errors must be trapped by the user as they will occur by faulty data and the like.

This keyword returns the cause of any error as follows:

Error Error Description
0 No Error
2 Boundary error when an integer variable is trying to access memory not on a boundary, this will also normally cause a general exception error.
3 Can’t initialise the SD Card when initsd is used.
4 Read sector error, this may also be accompanied by a file error, see ferror().
5 Problem with opening a file
6 Problem writing a file
7 None valid file number
8 Length of requested file is < 1
9 Square root value of < 1
10 Instring offset < 1 or > string length
11  ‘split’ the substring is too big to fit into length of the string space for a particular index.
12 ‘split’ too many substrings to fit into the number of indices available.
20 UART1 Buffer full
21 UART1 overrun (hardware buffer full)
22 UART2 Buffer full
23 UART2 overrun (hardware buffer full)

sys
sys

Returns a screen full of system information.

dump
dump
dump 0xa0000000

Displays 128 bytes of the given address in hex and ASCII format to the screen. NOTE trying to access memory outside the the range specified by the microcontroller will result in an exception error, dump 0 for example.

list
list <option> <function name>
list ram
list flash func1
list var

This has several uses as follows:

  1. A list of functions in FLASH or RAM can be listed by using ‘list flash’ or ‘list ram’. This gives the function names in the order that they were created.
  2. To list an individual function and see its contents use the name of the function after ‘flash’ or ‘ram’ as in the second example above.
  3. It is also possible to see a list of current variables using list ‘var’ this can be useful for debugging. Note also that when a function has been run for the first time it is referenced by an ‘INT’ variable the contents are the functions address.
run
run <file name><params>
run test

This will load a ‘.bas’ file into RAM and execute the function with the same name as the file name. The ‘.bas’ extension should not be included in the name following run.

This function is useful for writing large programs where sections can be loaded form the SD card as and when needed. Common section could be kept on the internal Flash.

chain
chain <file name><params>
chain test

** Chain may not work correctly at the time of release, this is still under development **

This does the same thing as run, except that is does NOT clear the global variables. This may be useful for retaining system information.

WARNING: Functions when first run are also global variables and these will not be cleared. If the functions existed in RAM then chain will replace them and so they will not exist anymore but the variables pointing to them will. If called the outcome will be unpredictable.