User`s manual

Rabbit 4000 Designer’s Handbook rabbit.com 61
7.1.2.1 Determining the Existence of the System ID Block
In Dynamic C versions prior to 7.20, and for ID block versions 1 and 2, the following sequence of events
is used by _readIDBlock() to determine if an ID block is present:
1. The 16 bytes at the top of the primary flash are read into a local buffer. (If a 256 KB flash is installed,
the 16 bytes starting at address 0x3FFF0 will be read.)
2. The last six bytes of the local buffer are checked for an alternating sequence of 0x55, 0xAA, 0x55,
0xAA, 0x55, 0xAA. If this is not found, the block does not exist and an error (-2) is returned.
3. The ID block size (=SIZE) is determined from the first 4 bytes of the 16-byte buffer.
4. A block of bytes containing all fields from the start of the SysIDBlock struct up to but not including
the reserved field is read from flash at address 0x40000-SIZE, essentially filling the SysIDBlock
struct except for the reserved field (since the top 16 bytes have been read earlier).
5. The CRC field is saved in a local variable, then set to 0x0000. A CRC check is then calculated for the
entire ID block except the reserved field and compared to the saved value. If they do not match, the
block is considered invalid and an error (-3) is returned. The CRC field is then restored. The reserved
field is avoided in the CRC check since its size may vary, depending on the size of the ID block.
Determining the existence of a valid mirrored ID block may be slightly more complicated, requiring the
above sequence of events to be repeated at several locations below the top of the primary flash. See
Figure 7.2 below for complete details.
Not all fields are filled in different versions of the ID block. The table below lists the first ID block version
that filled each field and whether that field is absolutely required by Dynamic C for normal operation.
(Much of the ID block data is useful, but not critical.)
Table 7-1 The System ID Block
Offset from
start of
block
Size
(bytes)
Description
Filled as
of Version
Required
00h 2 ID block version number 1 x
02h 2 Product ID 1 x
04h 2 Vendor ID 2
06h 7 Timestamp (YY/MM/D/H/M/S) 1
0Dh 4Flash ID 2
11h 2 Flash size (in 1000h pages) 2
13h 2 Flash sector size (in bytes) 2
15h 2 Number of sectors in flash 2
17h 2 Flash access time (nanoseconds) 4
19h 4 Flash ID, 2nd flash 2
1Dh 2 Flash size (in 1000h pages), 2nd flash 2
1Fh 2 Flash sector size, 2nd flash (in bytes) 2