
Functions.txt

This file contains the basic organization of the software for this project.
The organization of this file is such that a review of the desired functions
are provided with enough details to understand what the project task
is intended to perform and how it relates software wise with other tasks.
This file can be used as a checkoff of software functions as they are 
added to source code. Flow charts, lists of included files, routine
descriptions, code snipets, and hardware setup information, are possible

###### Test120 - base line rotuines for SiLabs 120TB #######

This directory is intended to be used for basic or baseline 
programming and testing of SiLabs 12x Target Boards that come
inside a DK - i.e. EthernetDK and 12xDK.

In the current programming state, after doing "d.bat" and updating
the TB with new code, type "go" at the "ok" prompt and the
TB will start the main loop, where the temperature of the CPU
is read and displayed on the serial port. The temperature is 
also stored in xram as well as a string of text is stored that
could be used with ethernet adapters doing sockets, HTTP or HTML 
network transfers.

This code is designed to test your development setup and get some
initial coding into a 12x TB. If your using a new TB, run the SiLabs
IDE, download to the TB the chip.hex file using the USB Debug
Adapter. Connect the serial cable to the TB's J5 and if all goes
well, after doing "go" you should see a display of several lines
of text plus a hex/ASCII dump of xram buffer space using putty or
serial com program set to 38400 8/1. Most terminal emulators will
see an updating fixed display, while windows dos box will just scroll
by.

The text handling code represents the current tools available in
myforth for moving text around. While not being a complete set of
text tools, it is enough, as shown, to create complex screen output,
or buffers of text for such things as HTML transfers. MyForth does
not have a full set of 32bit math routines at present, however the use
of the internal MAC can be helpful in some cases. SiLabs has not
provided any libraries of MAC assembler coding and thus what is shown
appears to work, but is not a full set of abilites by any means.

NOTES:
The code for converting from hex to C is not highly reliable -
it is an approximation only and provided to show example coding
using digit, MAC coding issues, and xram data moves.

Use internal clock ONLY as on board clock is 22.1184mhz.

###### software flow chart

  Boot device and check for program flash command
  Setup serial device and jump to start
  Start
     set initial vectors and base ram
     do  initialize hardware routines
     go main
         initialize ADC and CPU temp process
         clears display screen
         main loop
           reset to 0/0 on display
           read cpu temp and display
           turn led on and delay
           read cpu temp and store in xram
           turn led off and delay
           read extended ram and display data
         go back to main loop
  

###### modules used
*** current includes - beware of if - else.... ***
***                    might be some false includes ***

from command to build script
 Linux
  ${SOURCE}/amr/serial-linux.fs \
 Windows
  ${SOURCE}/amr/serial-windows.fs \

 Both
  ${SOURCE}/common/loader.fs \
     loader.fs:include ansi.fs  \ Part of Gforth.
     loader.fs:include gforth/vtags.fs use-tags
     loader.fs:include common/config.fs
     loader.fs:include myforth/compiler.fs
     loader.fs:include amr/saver.fs
          saver.fs:include amr/bin2hex.fs
     loader.fs:include myforth/dis5x.fs
     loader.fs:include amr/download-cygnal.fs
          download-cygnal.fs:\    include serial-windows.fs
          download-cygnal.fs:\ [else]     include serial-linux.fs
          download-cygnal.fs:\ include linuxcomm.fs
     loader.fs:include gforth/dumb.fs
     loader.fs:include myforth/misc8051.fs
     loader.fs:\ include job.fs

--> grep include *.fs

job.fs:include chip/sfr120.fs
job.fs:include chip/bootloader120.fs
job.fs: include amr/tether.fs
job.fs:[else]   include myforth/standalone.fs
job.fs:include myforth/debug.fs        \ Comes before application, useful tools.
job.fs:include set120xbr.fs            \ default hardware setup for 120 chips
job.fs:include ram_tools.fs            \ tools for extended ram access, display
job.fs:include get_temp.fs             \ stock get temperature routines
job.fs:include main.fs                 \ main functions to interface with PC
job.fs:include common/interactive.fs   \ Should come _after_ application for efficiency.


##### hardware setup
see set120xbr.fs for default layout of hardware registers and ports.

    P0.0  C12   TX0   J15-1     UART0 - Jumper J6 for Tx to J5-2 Tx Out
    P0.1  B12   RX0   J15-2     UART0 - Jumper J9 for Rx to J5-3 Rx In
    P1.6  C2    LED   J12-7     J3 - jumper to enable LED - default
   

##### Data Layout and Protocol

 At present a few extended memory locations are used.
 These help show how to access the extended memory.
 Example of hi-memory buffer spaces for storing values..

$2E00   constant id_byt    \ ascii ID high char
$2E01   constant id_byt    \ ascii ID low char
$2E02   constant ver_hi    \ software version high byte
$2E03   constant ver_lo    \ software version low byte
$2E04   constant tmp_hi    \ high byte of temperature
$2E05   constant tmp_lo    \ low  byte of temperature
$2E06   constant data_1    \ data value #1 ( high if double )
$2E07   constant data_2    \ data value #2 ( low  if double )
$2E08   constant data_3    \ data value #3 ( high if double )
$2E09   constant data_4    \ data value #4 ( low  if double )
$2E10   constant bufr_S    \ start of text buffer

##### function list

init-hdwre set xbr and other hardware to know state
init       main initialization routine of program
mainlp     main loop to read cpu temp and display data


##### history of changes:

01/04/2009 update this file with more data about project. bdk
12/28/2008 initial setup of functions.txt file by bdk.


