Data Reading from the SD CARD

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Data Reading from the SD CARD

1,197 次查看
Shashi_ranjan_14
Contributor II

Hello all,

I want to read data from an SD card. I can read the display, but they only print the "char" value. Can anyone teach me how to read a float or decimal value and print it? now i am using imxrt1050 board using mcuXpresso.

Thanks 

 

iMXRT1050 @nxp @IMXRT1050 

 

标记 (1)
0 项奖励
回复
3 回复数

1,141 次查看
Shashi_ranjan_14
Contributor II

We successfully write on the SD card and read from the SD card, while reading from SD card we were able get data via "char" only. To get the data we are receiving by using sprintf and fscanf function.

In SD card file we have provided integer data and we want to read data such as double and float.

 

For above technical support u provide solution as use float pointer for that can provide a example to execute?

 

0 项奖励
回复

1,123 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi @Shashi_ranjan_14 ,

Like these code

    char ch;
    float *p;
    char data[4];
    float i=3.14159;
    char *pd;
    PRINTF("%f\r\n",i);
    pd = (char*)&i;
    for(ch=0;ch<4;ch++)
    	data[ch]=*pd++;

    p=(float*)&data[0];
    PRINTF("%f\r\n",*p);

https://community.nxp.com/t5/i-MX-RT/How-to-print-the-quot-negative-float-point-number-quot-to-show/...

Regards,

Jing

0 项奖励
回复

1,178 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi @Shashi_ranjan_14 ,

You can use a float pointer to do this.

 

Regards,

Jing

0 项奖励
回复