Флешка MX29LV800 (в продакшене будет 320, а пока что нашёл) подключена со смещением адреса на 1, т.е. A0 флешки к A1 проца, и т.д.. Address shifting в SCS выключен (1). CS0 используется. Базовый адрес 0x80000000.
За основу взят код работы с SST39VF320 с lpcware http://sw.lpcware.com/?p=lpc177x_8x.git;a=...1577a053b843f69
Инициализация:
Код
config.CSn = 0;
config.AddressMirror = 0;
config.ByteLane = 1;
config.DataWidth = 16;
config.ExtendedWait = 1;//0;
config.PageMode = 0;
config.WaitWEn = 2;
config.WaitOEn = 2;
config.WaitWr = 0x1f;
config.WaitPage = 0x1f;
config.WaitRd = 0x1f;
config.WaitTurn = 0x1f;
StaticMem_Init(&config);
config.AddressMirror = 0;
config.ByteLane = 1;
config.DataWidth = 16;
config.ExtendedWait = 1;//0;
config.PageMode = 0;
config.WaitWEn = 2;
config.WaitOEn = 2;
config.WaitWr = 0x1f;
config.WaitPage = 0x1f;
config.WaitRd = 0x1f;
config.WaitTurn = 0x1f;
StaticMem_Init(&config);
Пытаюсь прочитать ID:
Код
ip = GET_ADDR(0x0555);
*ip = 0x00AA;
ip = GET_ADDR(0x02AA);
*ip = 0x0055;
ip = GET_ADDR(0x0555);
*ip = 0x0090;
delay(10);
ip = GET_ADDR(0x0000);
id1 = *ip;
ip = GET_ADDR(0x0001);
id2 = *ip;
*ip = 0x00AA;
ip = GET_ADDR(0x02AA);
*ip = 0x0055;
ip = GET_ADDR(0x0555);
*ip = 0x0090;
delay(10);
ip = GET_ADDR(0x0000);
id1 = *ip;
ip = GET_ADDR(0x0001);
id2 = *ip;
Получаю 0xD3A1 и 0xC280 соответственно. Если прочитать первые 10 слов:
Код
for(unsigned long i = 0; i < 10u; i++)
{
ip = GET_ADDR(i);
xprintf("== 0x%X\n", *ip);
}
{
ip = GET_ADDR(i);
xprintf("== 0x%X\n", *ip);
}
То получаю 0xD3A1 и 0xC280 первыми данными в памяти. Т.е. будто команды для чтения ID вообще не прошли и читаются тупо данные из 0 и 1 адреса.
GET_ADDR() сделан со смещением на 1 бит
Код
#define NOR_FLASH_BASE 0x80000000
#define GET_ADDR(addr) (volatile uint16_t *)(NOR_FLASH_BASE | ((addr)<<1))
#define GET_ADDR(addr) (volatile uint16_t *)(NOR_FLASH_BASE | ((addr)<<1))
Если сделать базовый адрес 0x90000000 и переключить флешку на CS1, то получаю те же данные.
Осциллографом вижу импульсы на WE, OE. RY/BY всегда в 1.
В даташите не совсем понял один момент:
Цитата
The MX29LV800C T/B also features the chip unprotected
mode, so that all sectors are unprotected after chip un-
protected is completed to incorporate any changes in the
code. It is recommended to protect all sectors before
activating chip unprotected mode.
To activate this mode, the programming equipment must
force VID on control pin OE# and address pin A9. The
CE# pins must be set at VIL. Pins A6 must be set to
VIH. Refer to chip unprotected algorithm and waveform
for the chip unprotected algorithm. The unprotection
mechanism begins on the falling edge of the WE# pulse
and is terminated on the rising edge.
It is also possible to determine if the chip is unprotected
in the system by writing the Read Silicon ID command.
Performing a read operation with A1=VIH, it will produce
00H at data outputs (Q0-Q7) for an unprotected sector.
It is noted that all sectors are unprotected after the chip
unprotected algorithm is completed.
mode, so that all sectors are unprotected after chip un-
protected is completed to incorporate any changes in the
code. It is recommended to protect all sectors before
activating chip unprotected mode.
To activate this mode, the programming equipment must
force VID on control pin OE# and address pin A9. The
CE# pins must be set at VIL. Pins A6 must be set to
VIH. Refer to chip unprotected algorithm and waveform
for the chip unprotected algorithm. The unprotection
mechanism begins on the falling edge of the WE# pulse
and is terminated on the rising edge.
It is also possible to determine if the chip is unprotected
in the system by writing the Read Silicon ID command.
Performing a read operation with A1=VIH, it will produce
00H at data outputs (Q0-Q7) for an unprotected sector.
It is noted that all sectors are unprotected after the chip
unprotected algorithm is completed.
Т.е. если память защищена от записи (а такое может быть т.к. флешка выпаяна из старого ноутбука), то запись работать не будет пока я не сделаю "unprotected mode". При этом если сделать чтение ID, то для незащищённых секторов она должна выдать нули. Как это понимать?
И ещё, в этом примере команды (адреса) записаны с лишним символом: 5555 вместо положенный по даташиту 555 и т.д. В примере кода что лежит на сайте Macronix команды записаны верно. Почему у NXP в командах лишний младший полубайт? В моём слкчае ничего не изменяется если убрать/добавить лишний полубайт.