About the Datalink
What is it?
[This Page] Download Protocol
Display Segments
Memory Map
150 vs 150s
EEProms

Wristapp Programming
Reference
Creating Wristapps
Wristapp Format
The State Table
Wristapp Routines
Wristapps

Wristapp Programming
Tutorials
1 - Hello World
2 - Getting Input
3 - Better Input
4 - Showing Selection
5 - PassWord
6 - Day Find
7 - Playing with Sound
8 - Using Callbacks
9 - Hex Dump
10 - EEPROM Dumper
11 - Spend Watch
12 - Sound Schemes
13 - Random Numbers
14 - Hourly Chimes
15 - Lottery Picker

Sound Schemes
Sound Hardware
Sound Scheme Format

Home Send Mail

Download Protocol - Synchronization Process

Before you can start sending any data to the datalink, you have to send a series of sync bytes:

$55 (the watch has to see 4 in a row to be happy about it)

Once the watch has gotten the Sync bytes, it will look for a series of at least four $AA or $BF bytes to go into an initialization mode.

Once in initialization mode, it will start looking for the data bytes. If it sees a $EF, it will treat that as an escape byte and read in the next byte regardless of what it is (this allows the first byte of the packet to be a $55, $AA, $BF or even $EF).

Once it has gone into data transfer mode, it expects a series of 2 byte groups where the low bit of the first byte and the high bit of the second byte (I call these the middle bits) must match to be sync bits. It expects these sync bits to alternate between 0 and 1. Any 2 byte group which does not match this will be thrown out. Also, if no valid bytes are received within 1/5 second, the transfer operation is aborted.

Sync Bits

With these sync bits, you can only transfer 14 bits of data for every 16 bits sent. (There are actually 2 extra sync bits on the screen to act as start and stop bits). If you look at it, that means that you can get 7 bytes transferred for every 8 bytes sent. The organization of these bits are:

   abcdefg- -ijklmnh
   qrstuop+ +yzABvwx
   GHICDEF- -OPJKLMN
   WQRSTUV+ +XYZ1234

Where - and + represent the sync bits (zero and one) in the byte pairs. If you decode these bits into the corresponding bytes, you get:

   abcdefgh
   ijklmnop
   qrstuvwx
   yzABCDEF
   GHIJKLMN
   OPQRSTUV
   WXYZ1234

Note that you always have to send in byte pairs, but the code is smart enough to throw away an extra byte which does not fit in a packet.   All packets end with a 2 byte 16-Bit CRC.

I think that the most interesting packet of all of this is the CPACKET_JMPMEM. It is possible to reset the watch by just sending this packet in the stream:
09 23 04 3e 18 94 81 <crc-16>

What this does is tells it to jump to location 04 3e which happens to be the address of where the 4th byte in the packet is stored. The code executes the 18 94 which is a BSET 4,TIMER_FLAGS followed by an 81 = RTS. When the watch sees that 4,TIMER_FLAGS has been set, it will run the watch through a complete reset cycle. There are a lot of other fun things that you can do. For example, you can play a tune during the download by storing new values at location 0335. So the packet:
0c 23 04 3e a6 01 c7 03 35 81 <crc-16>

Would change the download tone to be a LOW C. Replace the 01 with any value up to 0f and you can actually play a tune as it is downloading. (The note at $0335 is played after each packet).

You can also use this code to indicate a status on the watch by setting the individual segments on the bottom:
0d 23 04 3e a6 48 b7 1d 19 1e 81 <crc-16>

Would turn on the AM indicator. Of course since you can't look at the watch while it is downloading, it would be little silly. However, this can be a great debug aid for someone working on the download protocol since the symbols are not cleared out once the download process starts.

The CPACKET_MEM packet is also pretty useful. You can use it to set any of the locations in ram to a particular value. This might be useful if you know that you have a certain Wristapp already loaded and you want to change some data stored in the wristapp. All you need is the address to store the data in and the data that you want to put there.

Packet Format

$20 - CPACKET_START
0 Packet Length
1 $20 - CPACKET_START
2 $00
3 $00
4 Version: 3=V2.0 for the 150, 4=V2.1 for the 150s
5 CRC-16 High
6 CRC-16 Low

This skip packet does get sent to the Datalink, but its contents are completely ignored.
$21 - CPACKET_SKIP
0 Packet Length
1 $21 - CPACKET_SKIP
2 <ignored>
3 CRC-16 High
4 CRC-16 Low

This JMPMEM packet is useful for jumping to/calling specific locations in memory during the download process.
$23 - CPACKET_JMPMEM
0 Packet Length
1 $23 - CPACKET_JMPMEM
2 Address High to jump to
3 Address low to jump to
4 CRC-16 High
5 CRC-16 Low

This is the Initialization packet to start loading a section. There are three formats based on the section to be loaded.
$90 - CPACKET_SECT - Format 1
0 Packet Length
1 $90 - CPACKET_SECT
2 $01 - CLOAD_EEPROM - Load up EEProm data
3 Number of CPACKET_DATA packets to follow
4 CRC-16 High
5 CRC-16 Low
$90 - CPACKET_SECT - Format 2
0 Packet Length
1 $90 - CPACKET_SECT
2 $02 - CLOAD_WRISTAPP - Load a new Wristapp
3 Number of CPACKET_DATA packets to follow
4 Value to be stored in COMM_010e
5 CRC-16 High
6 CRC-16 Low
$90 - CPACKET_SECT - Format 3
0 Packet Length
1 $90 - CPACKET_SECT
2 $03 - CLOAD_SOUND - Load a new sound scheme
3 Number of CPACKET_DATA packets to follow
4 Base offset for the sound (should be $100-length of the sound)
5 CRC-16 High
6 CRC-16 Low

This is the data packet sent after a CPACKET_SECT. The number of packets sent will be dependent on the section and is indicated in the CPACKET_SECT packet. Once these packets start getting sent, there should be no other packets until a CPACKET_END is encountered (although there is really no error checking done on it). If the download is terminated without the last CPACKET_END being seen or the right number of CPACKET_DATA packets, the entire section is ignored.
$91 - CPACKET_DATA
0 Packet Length
1 $91 - CPACKET_DATA
2 <ignored> (probably address high)
3 <ignored> (probably address low)
4 .. n+4 n Databytes to be stored
n+5 CRC-16 High
n+6 CRC-16 Low

This packet marks the end of a section.
$92 - CPACKET_END
0 Packet Length
1 $92 - CPACKET_END
2 Section (1=CLOAD_EEPROM, 2=CLOAD_WRISTAPP, 3=CLOAD_SOUND)
3 CRC-16 High
4 CRC-16 Low

This Packet is used to clear out a section.
$93 - CPACKET_CLEAR
0 Packet Length
1 $93 - CPACKET_CLEAR
2 Section to clear (CLOAD_EEPROM, CLOAD_WRISTAPP, CLOAD_SOUND)
3 CRC-16 High
4 CRC-16 Low

This packet is used to set the alarm information for a single alarm.
$50 - CPACKET_ALARM
0 Packet Length
1 $50 - CPACKET_ALARM
2 Alarm Number (1-5)
3 Alarm Hour (0-23)
4 Alarm Minute (0-59)
5 <ignored>
6 <ignored>
7 Alarm String character 1
8 Alarm String character 2
9 Alarm String character 3
10 Alarm String character 4
11 Alarm String character 5
12 Alarm String character 6
13 Alarm String character 7
14 Alarm String character 8
15 Alarm enable 0=disable, non-zero=enable
16 CRC-16 High
17 CRC-16 Low

This single packet is used to set the time. It should be sent early in the process in ensure the best synchronization with the CPU clock time.
$32 - CPACKET_TIME
0 Packet Length
1 $32 - CPACKET_TIME
2 Time zone selector (1=Time zone 1)
3 Seconds (0-59)
4 Hour (0-23)
5 Minute (0-59)
6 Month of the year (1-12)
7 Day of the month (1-31)
8 Current year (mod 1900)
9 Time Zone Name character 1
10 Time Zone Name character 2
11 Time Zone Name character 3
12 Day of the week (0=Monday...6=Sunday)
13 12/24 hour selector (1=12 Hour format, anything other than 1=24 hour format)
14 Time zone date format
15 CRC-16 High
16 CRC-16 Low

This packet is used to store a number of bytes into memory at a fixed location. Note that it is not used for loading up a wristapp because other information has to be reset when a wristapp has been loaded.
$70 - CPACKET_MEM
0 Packet Length
1 $70 - CPACKET_MEM
2 High byte of memory address
3 Low byte of memory address
4..n+3 Data to be stored into memory
n+4 CRC-16 High
n+5 CRC-16 Low

This packet is used to control the hourly chimes and button beep flags.
$71 - CPACKET_BEEPS
0 Packet Length
1 $71 - CPACKET_BEEPS
2 Enable Hourly chimes flag (0=Disable, Non-Zero=Enable)
3 Enable Button beep flag (0=Disable, Non-Zero=Enable)
4 CRC-16 High
5 CRC-16 Low

1