[En-Nut-Discussion] Bug Fix for SpiMemRead, Ethernut 2, Data Flash reading.
Brett Abbott
Brett.Abbott at digital-telemetry.com
Fri Apr 14 11:29:36 CEST 2006
Hi
re: Ethernut 2 Data Flash. Unreliable reading of data in some scenarios.
For those few people who use SpiMemRead, there is a fix which may be
required. Ive ported it to ICCAVR and found unreliable use until I
added the "8 dont care" bits referred to in the data spec.
Replacement code below. Hope it helps.
Cheers
Brett
int SpiMemRead(u_short page, u_char *data, u_short len)
{
// Main Memory Page to Buffer Transfer
// 0x53, followed by 4 reserved, 11 address, 9 dont care
// 0x53, 0000xxxx xxxxxxx0 00000000
// Buffer Read: 0x54, followed by 15reserved (0), 9 address
(pagenum), 8 dont care
// 0x54, 00000000 0000000x xxxxxxxx 00000000
// u_char buf_cmd[] = { 0x54, 0, 0, 0 }; // Original line
u_char buf_cmd[] = { 0x54, 0, 0, 0, 0 }; // Added 5th byte, Brett
Abbott, 14Apr06
sbi(SPIMEM_CS_PORT, SPIMEM_CS_BIT);
SpiByte(0x53);
SpiByte(page >> 7);
SpiByte(page << 1);
SpiByte(0x00);
cbi(SPIMEM_CS_PORT, SPIMEM_CS_BIT);
while((SpiMemStatus() & 0x80) == 0);
sbi(SPIMEM_CS_PORT, SPIMEM_CS_BIT);
SpiWrite(buf_cmd, sizeof(buf_cmd));
SpiRead(data, len);
cbi(SPIMEM_CS_PORT, SPIMEM_CS_BIT);
return 0;
}
--
-----------------------------------------------------------------
Brett Abbott, Managing Director, Digital Telemetry Limited
Email: Brett.Abbott at digital-telemetry.com
PO Box 24 036 Manners Street, Wellington, New Zealand
Phone +64 (4) 5666-860 Mobile +64 (21) 656-144
------------------- Commercial in confidence --------------------
More information about the En-Nut-Discussion
mailing list