chiark / gitweb /
documentation for processor memory map
[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 RAM (data) memory map
23 =====================
24
25 The data memory map (for PIC18F458) looks like this:
26
27  0x000-0x05f    Access bank RAM - RAM locations accessible via
28                  access bank instructions; also form part of
29                  RAM page 0
30  0x060-0x0ff    Remainder of RAM page 0, accessible only via correct
31                  BSR setting (ie, BSR==0), INDF, etc.
32
33  0x100-0x1ff    RAM page 1, accessible only via bank switching etc.
34  0x200-0x2ff    RAM page 2, accessible only via bank switching etc.
35  0x300-0x3ff    RAM page 3, accessible only via bank switching etc.
36  0x400-0x4ff    RAM page 4, accessible only via bank switching etc.
37  0x500-0x5ff    RAM page 5, accessible only via bank switching etc.
38
39  0x600-0xeff    Nothing here, don't try to access.
40
41  0xf00-0xf5f    SFR's (memory-mapped peripherals etc.) accessible
42                  only via correct BSR, INDF, etc - but these are only
43                  the CAN SFR's and we do not use the CAN controller.
44  0xf60-0xfff    SFR's accessible via access bank (also form part
45                  of RAM page 15).
46
47
48 See common.inc for actual uses of the RAM areas.
49
50
51 Program (flash etc.) memory map
52 ===============================
53
54 Program memory map (for PIC18F458) looks like this:
55
56   0x00 0000-    Program memory
57   0x00 7fff      Contains actual program instructions and can also
58                  contain preprogrammed data provided via special .asm
59                  files.  Notable contents and addresses:
60                    0x00 0000  reset vector
61                    0x00 0008  high-priority interrupt vector
62                    0x00 0018  low-priority interrupt vector
63                  See common.inc for some special tables in here, for
64                  morse messages, pin/hardware-object definitions, etc.
65                  
66   0x20 0000-    ID locations
67   0x20 0007      Programming which varies per PIC.  Programmed by
68                  idlocs*.asm which are made by make-idlocs and
69                  included in perpic*.hex.  Contents:
70
71                 0x20 0000
72                   bits 7-5 = 000
73                   bits 4-0 = PIC number (guaranteed to be
74                              in the range 0..31 inclusive)
75                 0x20 0001
76                   bit 7     = 1 for the main PIC (#0)
77                               0 otherwise
78                   bits 0-6  = currently unused, set to 0
79
80                 0x20 0002-  } not currently used,
81                 0x20 0007   }  may contain anything
82                  
83   0x30 0000-    Hardware configuration
84   0x30 000f      Defines (clock source, WDT operation, etc.)
85                  Probably best not to touch.  `config.asm' provides
86                  correct contents, which is included in *-withcfg.hex
87                  and perpic*.hex.
88                  
89   0x3f fffe-    Hardware device ID
90   0x3f ffff      Fixed at manufacturing time; can be read to discover
91                  hardware type and version (probably not very useful)
92
93   0xf0 0000-    EEPROM data area
94   0xf0 00ff      Not currently used by us
95
96   0x01 0000-    } These locations, not listed above,       
97   0x1f ffff     }   do not correspond to anything - there  
98   0x20 0008-    }   is no hardware or memory in the chip   
99   0x2f ffff     }   at these locations.                    
100   0x30 0010-    }
101   0x3f fffd     } Accessing them isn't useful
102   0x40 0000-    }   and should probably be avoided.
103   0xef ffff     }
104
105
106 (Buffer page 50 0000h reserved for NMRA)    XXXX these look wrong
107 (Buffer page 40 0000h reserved for i2c)     XXXX   -iwj
108
109
110
111 I2C
112 ===
113 (slave addresses will be 10xxxxx where xxxxx=PIC number above)