I am using Attiny1616 with Microchip Studio.
I want to store the float type results obtained from the calculation of the code in FLASH memory.
I have looked into PROGMEM, but PROGMEM does not support the float data type.
So I tried to convert the float type result to char type data using snprintf or dtostrf and save it, but it did not work.
This is my C code.
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
const char test[] PROGMEM = "Hello, world!";
char buf[5] = "";
float cal_result = 10.83;
//dtostrf(cal_result, 5, 2, buf);
snprintf(buf, 6, "%f", cal_result);
const char out[5] PROGMEM = {buf[0],buf[1],buf[2],buf[3],buf[4]};
while(1){
}
}
Thank you in advance.
const float PROGMEM cal_result = 10.83f;fails for you?