#avr Logs

Oct 12 2018

#avr Calendar

12:19 AM rue_mohr: test
12:23 AM jesseg: roger
09:04 AM rue_mohr: --
01:50 PM ponA: hi everybody! I am just trying to get a lookup table into the program memory of my ATtiny13
01:51 PM ponA: i saw people suggesting __flash to do that, but i get the error '__flash' does not name a type
01:51 PM ponA: do i have to include anything to get __flash to work?
01:54 PM polprog: you might have an old setup, i never used __flash, i know PROGMEM works
01:54 PM polprog: ponA: https://www.nongnu.org/avr-libc/user-manual/pgmspace.html
01:55 PM ponA: i am using AtmelStudio 7
01:56 PM ponA: also, i tried using progmem, but it did not work, let me redo that really quick so i can get you detailed info
01:58 PM polprog: i think you can just paste the code somwehere
01:58 PM polprog: what di you mean it didnt work? haveyou used the right macros/functions?
02:01 PM ponA: i used uint8_t array[10] PROGMEM = {...10byte...} and my data memory usage increased by 10 bytes
02:02 PM ponA: of course i used #include <avr/pgmspace.h> beforehand
02:02 PM polprog: the .text or .data section?
02:04 PM ponA: ahh, okay, i got what you mean by that, text stayed the same, data increased by 10
02:06 PM ponA: so i thought the data value would be RAM and the value under text would be flash
02:07 PM polprog: no, the data is stored in flash and you have to access it using functions that use the LPM instructions
02:08 PM polprog: they are in <avr/progmem.h>, a
02:08 PM polprog: and the manual i linked
02:09 PM ponA: i use an attiny13, it has 1k bytes flash and 64 bytes sram
02:09 PM polprog: with 64b of sram you dont have much choice, ALL the strings must be in progmem
02:09 PM ponA: Program Memory Usage : 524 bytes 51,2 % Full
02:09 PM ponA: Data Memory Usage: 20 bytes 31,3 % Full
02:09 PM polprog: ok, so this is the usage at the very start
02:10 PM ponA: if i increase the array size of the PROGMEM array, the Data Memory Usage increases and i cant increase it to 100 bytes
02:10 PM ponA: (151% full), so it is definately not stored in flash
02:10 PM polprog: okay
02:10 PM polprog: post the code
02:11 PM polprog: or read the manual, it has examples
02:11 PM polprog: do you by any chance store strings in that array?
02:12 PM ponA: no, i want to store actual uint8_t bytes
02:13 PM polprog: char[10] PROGMEM = {1,2,3,4,5,6,7,8,9,10};
02:13 PM polprog: this has to go to program mem
02:14 PM polprog: if it goes to data memory, your compiler setup may be wrong
02:14 PM polprog: must*
02:16 PM ponA: i'll try it with a minimalistic program
02:18 PM ponA: ahh, i think i might have done a booboo while i try reading the data
02:32 PM ponA: okay, i dont get that... here is my minimalistic code: https://pastebin.com/FupmYbGD
02:32 PM Emil: Consider joining #avrs
02:33 PM ponA: thx for the hint, but polprog might still be able to solve that :)
02:33 PM polprog: im there as well really
02:33 PM polprog: ;)
02:34 PM ponA: so should i switch to there?
02:34 PM polprog: i guess, its more active
02:34 PM ponA: this code gets me 0% data memory usage, how would it do that? I definately have a uint32_t variable in SRAM
02:34 PM polprog: it might be allocated in one of the registers
02:35 PM polprog: if you called a function though...
02:35 PM polprog: you might get runtime sram usage, i dont think the compiler/makefile tells you that because its not that easy to estimate (you'd have to run your program)
02:36 PM polprog: basiaclly, this is ho it should be done
02:36 PM polprog: how*
02:36 PM ponA: okay, but if i shorten my flash_array to 8 Bytes, i still get the same Program Memory Usage of 182 Bytes
02:37 PM polprog: thats quite odd
02:37 PM ponA: does the makefile not take PROGMEM into account?
02:38 PM polprog: the compiler places the progmem in .text, makefile takes the output of avr-size command
02:38 PM ponA: so it should definately alter the value under "text", but it doesnt :/
02:39 PM polprog: define flash_array as static or global
02:40 PM ponA: global isnt recognized by the compiler (not declared in scope)
02:40 PM ponA: variable 'flash_array' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
02:40 PM polprog: global variable is a one thats outside functions
02:40 PM polprog: like
02:41 PM ponA: ahh, i'm such a fool :D
02:41 PM polprog: or make it static if you dont like globals
02:41 PM ponA: okay, NOW it worked
02:41 PM polprog: basically why this happens is that C automatic variables are stored on stack/in registers
02:41 PM polprog: automatic variables are the ones defined in functions, simplyfying
02:42 PM polprog: and Emil pointed out that it needs to be static or global in the second channel, #avrs :P i confess!
02:42 PM ponA: okay, i'll remember to use only global progmem variables in the future :)
02:42 PM polprog: or static, some people discourage global vars
02:43 PM polprog: i encourage you to join #avrs, this channel is pretty dead honestly
02:43 PM ponA: static didnt work, got a compile error
02:44 PM polprog: where did you define it static? in main() or outside?
02:44 PM ponA: inside
02:44 PM ponA: thx very much for the help!!
02:45 PM polprog: np!
03:54 PM nabil_ is now known as nabil
03:59 PM MarcinWieczorek_ is now known as MarcinWieczorek
05:50 PM [1]MrMobius is now known as MrMobius
11:28 PM vmt is now known as rms
11:29 PM rms is now known as Guest84768
11:30 PM Guest84768 is now known as vmt
11:55 PM day__ is now known as day