Буфер флэшки пишется и читается, но во флэш не записывается. Для теста пишу в нулевую страницу, пробывал писать в другие страницы с тем же результатом, вроде все правильно делаю.
Код: Выделить всё
void at45_init(void)
{
reset_spi1_high();
cs_spi1_high();
wp_spi1_high();
}
void at45_write_page(unsigned int addr)
{
volatile unsigned int i;
cs_spi1_low();
send_spi1_byte(0x84);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
for(i = 0;i < 264; i++)
{
send_spi1_byte((char)(i));
}
cs_spi1_high();
wait(10000);
cs_spi1_low();
send_spi1_byte(0x83);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
cs_spi1_high();
wait(1000000);
}
void at45_read_page(unsigned int addr)
{
volatile unsigned int i;
cs_spi1_low();
send_spi1_byte(0x53);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
cs_spi1_high();
wait(10000);
cs_spi1_low();
send_spi1_byte(0xD4);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
send_spi1_byte(0x00);
for(i = 0;i < 264; i++)
{
send_spi1_byte(0);
at45_read_buf[i] = read_spi1_byte();
}
cs_spi1_high();
}
