![]() It looks a little bit intimidated but it actually quite simple, it not only tell the avr-gcc that the string literal s should be kept in program memory (i.e. PSTR came into Arduino from part of avr-libs(a C library) defined in avr/pgmspace.h, it is actually a macro, not a function as many think it was, and is defined as: #define PSTR(s) ((const PROGMEM char *)(s)) Serial.println((int)&top_of_stack - (int)_brkval) Įxplain in detail what exactly does each of the keywords F(), (PGM_P)F, PSTR, const PROGMEM. ![]() Serial.println(((int)&top_of_stack - (int)&_heap_start)) A simple corrected version for AVR that I used is here: extern unsigned int _heap_start Return _brkval ? &top - _brkval : &top - _malloc_heap_start įirst, the freeMemory() function that you used from Adafruit was originated from a github, I don't know about the _arm_ implementation, but for the avr, it is incomplete for handling the corner case when the program does not use the malloc() function, if your program never use malloc(), the formula used in freeMemory() will produce the wrong result. #elif defined(CORE_TEENSY) || (ARDUINO > 103 & ARDUINO != 151) should use uinstd.h to define sbrk but Due causes a conflict Now all different methods report a free ram of 2299, including the simple Serial.print(). For example, at the last example (PROGMEM, strcpy_P) when I included another Serial.print(freeMemory()) before the call of the printing functions, then both freeMemory() calls report 2299!Īnother interesting problem is that the freeMemory() reports 2299 as freeRam, while the SRAM of my arduino UNO is only 2kbytes.įollowing the suggestion in comments, I changed "test" to "testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttest". Also it would be really useful if you could explain in detail what exactly does each of the keywords F(), (PGM_P)F, PSTR, const PROGMEM.ĭepending on where and how I use the call Serial.print(freeMemory()) the results change. The basic point of this question is to gather all the possible Flash memory printing techniques. I created a program that prints the word "test", with various methods: At the same time, I have been using the freeMemory() function from Adafruit. I have been testing on an Arduino UNO various techniques for serial printing from Flash Memory instead of RAM.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |