4 NMRA packets from the computer to the PIC should consist of 8-bit bytes.
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
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)
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.
17 most significant bit first
25 The data memory map (for PIC18F458) looks like this:
27 0x000-0x05f Access bank RAM - RAM locations accessible via
28 access bank instructions; also form part of
30 0x060-0x0ff Remainder of RAM page 0, accessible only via correct
31 BSR setting (ie, BSR==0), INDF, etc.
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.
39 0x600-0xeff Nothing here, don't try to access.
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
48 See common.inc for actual uses of the RAM areas.
51 Program (flash etc.) memory map
52 ===============================
54 Program memory map (for PIC18F458) looks like this:
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.
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:
73 bits 4-0 = PIC number (guaranteed to be
74 in the range 0..31 inclusive)
76 bit 7 = 1 for the main PIC (#0)
78 bits 0-6 = currently unused, set to 0
80 0x20 0002- } not currently used,
81 0x20 0007 } may contain anything
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
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)
93 0xf0 0000- EEPROM data area
94 0xf0 00ff Not currently used by us
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.
101 0x3f fffd } Accessing them isn't useful
102 0x40 0000- } and should probably be avoided.
106 (Buffer page 50 0000h reserved for NMRA) XXXX these look wrong
107 (Buffer page 40 0000h reserved for i2c) XXXX -iwj
113 (slave addresses will be 10xxxxx where xxxxx=PIC number above)