Remote Target - TLM

The Target Link Monitor is a small, ~512 byte, program that allows the communication with the Host PC and implements multitasking. This small program is however self contained. It requires no further code to allow full modification and inspection of all the PIC18Fs resources.

This is all carried out by the word SERVER which is defined as follows:

: SERVER (S - ) BEGIN >STACK EXECUTE AGAIN ;

We must thank the University of Rostock, in what was East Germany, for this deceptively simple idea. The words >STACK waits for the Host to send two bytes of data, LSB first, to the Target stack. This 16 bit value must be a valid CFA, Code Field Address, of an existing Target definition. The word EXECUTE performs a branch to this address by placing it in PCLATH and PCL.

Note: The address range is only 16bit so this limits the TLM use to 64k Flash devices.

The basic TLM words are:

>STACK, C@, C!, EXECUTE, PAUSE, @, !, SERVER, SP@, STOP, STACK>

With only these it is possible for SERVER to interrogate the PIC18F internals.

For example, if we wish to look at the current value of the PORTB register, we need to perform a C@ and send the result to the Host for display. This is what happens:

  I/O PORTB C@ H. <cr>

Host sends CFA of >STACK, EXECUTE runs it.

Host sends $F81 (PORTB) which >STACK puts on Target stack.

Host sends CFA of C@, EXECUTE runs it and C@ fetches the value.

Host sends CFA of STACK>, EXECUTE runs it and sends result to Host.

Host displays the 16 bit value in Hex.

SP@ puts the value of the stack pointer, DP ,on the stack so using STACK> and C@ the Host may display the current Target stack contents. When in the Remote mode, .S does this function.

With C! the Host may modify PIC18F resources. This allows you to write Host programs that require no further Target code but that will exercise hardware external to the PIC18F. This is very useful in development and production, to do initial testing

 

Contents