The primary aim was to create a useful project to stretch the 256 word flash memory and limited IO (3 output and 1 input lines) of the PIC10F200 processor. Due to the limited flash space it became obvious that the code would need to be created in assembly language.

Initially testing was perfomed with the slighty larger 12F509 which has 6 IO pins and 1k words of flash, using using a Pickit2 with the low pin count board which allows testing bit banger serial IO via the Pickit2 UART tool.

After sorting the serial IO code was added to control the TPI connections to an Attiny 10 processor.

This involved the usual reading and re reading the data sheet for the Attiny after which it became apparent that the following routines would be required:

A routine to enable/disable the Attiny via the reset pin and hence enter/exit programming mode.

A TPI send byte routine which serially transmits to the Attiny

A TPI receive byte routine to get data from the Attiny

After that it was just -:) a case of tieing the above routines together to enable the Attiny by sending the appropriate 9 byte program enable key and send various access layer commands to read or write the flash.

Two problems then had to be solved before moving the code to the 10F200:

1. There were not enough pins available to handle 3 TPI control and 2 serial IO pins.

One pin was saved by using a technique found on Ralph Doncasters Blog to handle serail IO via one pin, take a look at http://nerdralph.blogspot.co.uk/2014/11/se8r01-24ghz-wireless-modules.html . I took his hardware idea ( thanks Ralph for the idea) and created PIC version of the assembler routines

But I was still short of 1 output pin for the TPI stuff ... again One of Ralphs ideas came to my assistance, http://nerdralph.blogspot.co.uk/2014/01/nrf24l01-control-with-3-attiny85-pins.html, which made it possible to use one pin to handle both the TPI clock and the Attiny reset pin.

2. The code was just TOO big ....

The only answer to this was to find areas that could be removed/compressed and to re think what was the absolute minimum required to program the destination Attiny. It came down to the following:

1 A command to enable and disable the chip

2 Method of setting the desired chip word address

3 A command to read one word from the chip

4 A command to write a word to flash

5 A command to Erase the flash

The programmer prompts with a newline followed by '#' symbol and waits for a character and treats that character as follows

N.B. All commands and hex alpha characters MUST be upper case.

The serial port command interface uses 8 commands A - H

A = "Address" sets the programmers address pointer needs to be followed by 4 hex digits 0-9 A-F

(ignores all non valid characters)

B = "Begin" enters programming mode

C = not used

D = "Disconnect" which exits programming mode and start the target Attiny running

E = not used

F = "Format" erase the flash of the target

G = "Get" reads the data form the current address and increments the address pointer and outputs it as 4 hex digits to the serial port

H = "Hexedit" waits for 4 hex digits and then immediately writes them to the current address , it also increments the local address pointer.

All other values just return to the prompt.

So it is possible using the above to program a target Attiny chip diretcly from a terminal e.g. teraterm

but not a lot of fun!!!!!

Simple Serial

A simple application was written to use the above commans to read a hex file, write it to the target and then starts the target chip:

On startup the application looks for USB serial ports and if it find them it opens an displays a list, if no serial ports are found it just exist silently.Once loaded select the port that it is connected to an click start. Click on the lower text box and hit the space bar ( an invalid command) it should then display a # prompt . At this point the above commands can be used.

As a test hit B it should echo the character and return the # prompt , then hit A3FC0 again it should echo and return the prompt. Press G it should show G1E90 the #prompt press G again and see G03FF which is the device ID ( assuming this is an Attiny 10)

Type A0040 then G should show G0000. Type H1234 then A0040 G should show G1234. This shows a write o the Ram of the first word of the chip .

See the attached image.