新手上路
- 积分
- 40
- 金钱
- 40
- 注册时间
- 2022-8-11
- 在线时间
- 7 小时
|
这是我的主函数,flash为W25Q128, BMP_Pressure是我的传感器采集的数据,我把传感器的double类型数据拆分成几个字节的u8类型,当我W25QXX_Write((u8*)TEXT_Buffer_ZH,WriteAddr_ZH,2100); 写入的字节数大于2100时就会出现:第一个采集到的数据正常,第二个开始采集BMP_Pressure为0。小于2100时没有问题,但是我需要写入数据很多,无法写入
顺便问一下,为什么写入字节数最大为65535,可是我写入65535时,串口接收不到任何数据
double WRITE_BUFF;
u32 WRITE_BUFF_ZH;
u32 WRITE_BUFF_YU;
u8 TEXT_Buffer_ZH[8192];
u8 TEXT_Buffer_YU[8192];
double READ_BUFF;
u32 READ_BUFF_ZH;
double READ_BUFF_YU;
#define SIZE_ZH sizeof(TEXT_Buffer_ZH)
#define SIZE_YU sizeof(TEXT_Buffer_YU)
double P_BUFF[4000];
int main(void)
{
u8 key;
u16 i=0;
u16 j=0;
u32 WriteAddr_ZH=0X000000;
u32 WriteAddr_YU=0X080000;
u32 ReadAddr=0X000000;
u8 datatemp_ZH[8192];
u8 datatemp_YU[8192];
double t=0;
double BMP_Pressure,BMP_Temperature;
delay_init(); //ÑÓʱº¯Êý³õʼ»¯
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//ÉèÖÃÖжÏÓÅÏȼ¶·Ö×éΪ×é2£º2λÇÀÕ¼ÓÅÏȼ¶£¬2λÏìÓ¦ÓÅÏȼ¶
uart_init(115200); //´®¿Ú³õʼ»¯Îª115200
LED_Init(); //³õʼ»¯ÓëLEDÁ¬½ÓµÄÓ²¼þ½Ó¿Ú
IIC_Init();
W25QXX_Init(); //W25QXX³õʼ»¯
Bmp_Init();
// printf("BMP280´óÆøѹÁ¦´«¸ÐÆ÷ʵÑé\r\n");
delay_ms(50);
while(1)
{
while(BMP280_GetStatus(BMP280_MEASURING) != RESET);
while(BMP280_GetStatus(BMP280_IM_UPDATE) != RESET);
BMP_Temperature = BMP280_Get_Temperature();
BMP_Pressure= BMP280_Get_Pressure();
P_BUFF[j]=BMP_Pressure;
WRITE_BUFF=P_BUFF[j];
WRITE_BUFF_ZH=floor(WRITE_BUFF);
WRITE_BUFF_YU=(WRITE_BUFF-floor(WRITE_BUFF))*1000000;
TEXT_Buffer_ZH[i]=WRITE_BUFF_ZH/(256*256);
TEXT_Buffer_ZH[i+1]=WRITE_BUFF_ZH/256;
TEXT_Buffer_ZH[i+2]=WRITE_BUFF_ZH%(256*256);
TEXT_Buffer_YU[i]=WRITE_BUFF_YU/(256*256);
TEXT_Buffer_YU[i+1]=WRITE_BUFF_YU/256;
TEXT_Buffer_YU[i+2]=WRITE_BUFF_YU%(256*256);
// READ_BUFF=TEXT_Buffer_ZH[i+0]*256*256+TEXT_Buffer_ZH[i+1]*256+TEXT_Buffer_ZH[i+2]+((double)((TEXT_Buffer_YU[i+0]*256*256+TEXT_Buffer_YU[i+1]*256+TEXT_Buffer_YU[i+2])))/1000000;
//
W25QXX_Write((u8*)TEXT_Buffer_ZH,WriteAddr_ZH,2100);
W25QXX_Write((u8*)TEXT_Buffer_YU,WriteAddr_YU,2100);
W25QXX_Read(datatemp_ZH,WriteAddr_ZH,2100);
W25QXX_Read(datatemp_YU,WriteAddr_YU,2100);
WriteAddr_ZH=WriteAddr_ZH+0X000003;
WriteAddr_YU=WriteAddr_YU+0X000003;
READ_BUFF=datatemp_ZH[i]*256*256+datatemp_ZH[i+1]*256+datatemp_ZH[i+2]+((double)((datatemp_YU[i]*256*256+datatemp_YU[i+1]*256+datatemp_YU[i+2])))/1000000;
//// ReadAddr=ReadAddr+0X000006;
i=i+3;
printf("%f \r\n",READ_BUFF);
// printf("%d \r\n",WriteAddr);
// delay_ms(50);
j++;
LED0=!LED0;
}
}
|
|