大致如下:
write_enable()
{
cs = 0;
write_byte(0x06);
cs = 1;
}
write_disbale()
{
cs = 0;
write_byte(0x04);
cs = 1;
}
write_protect()
{
cs = 0;
write_byte(0x01);
write_byte(0x1c);//保护全部 BP2 =1, BP1=1, BP0 =1
cs = 1;
}
write_unprotect()
{
cs = 0;
write_byte(0x01);
write_byte(0x00);//解除保护
cs = 1;
}
大概的函数如上,现在是这样,不加写保护的话,数据是非常正常的,可读可写可擦
现在改成,如下所示后,包括擦除函数也是,前加了解除保护,后加了保护后,变成可读不可写不可擦
大概意思就是想在写数据或擦数据写先解除保护,操作完后再加上保护, 写保护与解除保护有问题词吗??
write_data()
{
write_enable();
write_unprotect()
写数据,略
write_protect()
write_disbale()
}
|