chiark / gitweb /
8/4/5
[trains.git] / cebpic / README.protocol
1 NMRA
2 ====
3
4 NMRA packets from the computer to the PIC should consist of 8-bit bytes.
5
6 bits 6-0 contain the data to be sent to the track
7 bit 7 is 1 if the byte is the last in the packet and 0 otherwise
8  
9 The first 14 data bits in the NMRA packet should be 1s.
10 (i.e. the first two complete bytes should be 01111111 01111111)
11 (packets beginning with some other sequence are reserved for non-NMRA messages)
12
13 Maximum NMRA message length = 15 bytes (i.e. 105 bits).
14 Messages longer than this will cause things to get confused at the moment.
15
16 baud rate 9600
17 most significant bit first
18 8n1
19
20
21
22 Reserved access bank locations
23 ==============================
24 00h = WREG2
25 01h = WREG3
26 02h = WREG4
27
28
29 Flash memory ID locations
30 =========================
31
32 (Buffer page 50 0000h reserved for NMRA)
33 (Buffer page 40 0000h reserved for i2c)
34 (Buffer page 50 0000h reserved for error codes)
35
36 Byte 40 0000h
37                 bits 7-5        = 000
38                 bits 4-0        PIC number 
39                                 (guaranteed to be in range 0..31 inclusive)
40                 
41
42 Byte 40 0001h
43                 bit 7           1 for the main PIC (#0)
44                                 0 otherwise
45                 0-6             currently unused, set to 0
46
47 Bytes 30 0000h - 3f ffffh
48                 reserved for error messages, each 8 bytes long 
49                 
50
51
52
53
54 I2C
55 ===
56 (slave addresses will be 10xxxxx where xxxxx=PIC number above)