How to, Write to flash – Sundance SMT118 User Manual
Page 17

Version 1.0
Page 17 of 20
SMT118v2 User Manual
How To
This section is intended to provide code segments showing the operation of some of
the SMT118’s features. All of the code has been written for the SMT3x5 TIM, but
could easily be recompiled for another module.
In these examples, two functions, read_global and write_global are used to
access resources on the global bus. The parameters required are a 32 bit address
and optionally the data word.
Write to flash
The flash device fitted on the SMT118 has a write protect mechanism. This flash
device supports many different operations, and it is suggested that the data sheet be
read for full information. The part number is Am29LV160B.
#define flash 0xF8000000
#define flash1 0xF8000AAA
#define flash2 0xF8000555
In this function, the flash must be set to byte mode and the addr parameter is an
offset from the start of the flash.
write_flash(unsigned int addr, unsigned int data)
{
write_global(flash1, 0xAA);
write_global(flash2, 0x55);
write_global(flash1, 0xA0);
write_global(flash+addr, data);
while( (read_global(flash+addr) & 0xFF) != (data & 0xFF));
}