cal_p[0] = (touch_para.An*1.0)/touch_para.Divider; // aa1
cal_p[1] = (touch_para.Bn*1.0)/touch_para.Divider; // bb1
cal_p[2] = (touch_para.Cn*1.0)/touch_para.Divider; // cc1
cal_p[3] = (touch_para.Dn*1.0)/touch_para.Divider; // aa2
cal_p[4] = (touch_para.En*1.0)/touch_para.Divider; // bb2
cal_p[5] = (touch_para.Fn*1.0)/touch_para.Divider; // cc2
{
cal_flag = 0x55;
SPI_FLASH_SectorErase(0);
SPI_FLASH_BufferWrite(&cal_flag, 0, 1);
SPI_FLASH_BufferWrite((void*)cal_p, 1, sizeof(cal_p));
for( k=0; k<6; k++ )
printf(&quot;\r\n tx = %LF \r\n&quot;,cal_p[k]);
printf(&quot;\r\n test1 = %x \r\n&quot;,cal_flag); //打印出标志位
}
for( k=0; k<6; k++ ) //把数据清空
{
cal_p[k]=0;
}
for( k=0; k<6; k++ )
printf(&quot;\r\n test = %f \r\n&quot;,cal_p[k]);
SPI_FLASH_BufferRead(&cal_flag, 0, 1);
printf(&quot;\r\n test2 = %x \r\n&quot;,cal_flag); //以读的方式打印出标志位
SPI_FLASH_BufferRead((void*)cal_p, 1, sizeof(cal_p));
SPI_FLASH_CS_HIGH();
for( k=0; k<6; k++ )
printf(&quot;\r\n rx = %f \r\n&quot;,cal_p[k]);
数据写入和读出分别打印的内容都是一样,但是断电之后在主函数读flash时内容的怎么都是其他数据;
SysTick_Init();
LED_GPIO_Config();
LCD_Init();
/* GRAM扫描方向为左下脚->右上角 */
Lcd_GramScan(2);
LCD_Clear(0, 0, 320, 240, BACKGROUND);
USART1_Config();
SPI_FLASH_Init();
SPI_FLASH_SectorErase(0);
SPI_FLASH_BufferRead((void*)cal_p, 1, sizeof(cal_p)); //复位后在mian读取flash
SPI_FLASH_CS_HIGH();
for( k=0; k<6; k++ )
printf(&quot;\r\n rx = %x \r\n&quot;,cal_p[k]);
/* 触摸屏IO和中断初始化 */
Touch_Init();
串口数据:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
tx = 0.090032
tx = -0.002450
tx = -14.310098
tx = -0.000755
tx = 0.065225
tx = -15.362291
test1 = 55
test = 0.000000 //数组清理一遍
test = 0.000000
test = 0.000000
test = 0.000000
test = 0.000000
test = 0.000000
test2 = 55
rx = 0.090032 //按这段来说可以保证数据都是读出来的吧
rx = -0.002450
rx = -14.310098
rx = -0.000755
rx = 0.065225
rx = -15.362291
rx = 10 //这些是复位读取的,数据都没有了
rx = 40
rx = 40
rx = 40
rx = 40
rx = 40
为什么会这样????????????????????? |