#avr Logs

Aug 08 2020

#avr Calendar

01:00 AM Red_Tide: Hey so read this thing about the avr registers and it is a little poorly translated and unclear it suggests that somehow r0-r15 are different from r16-r31
01:06 AM Red_Tide: anyone know what this is about?
01:36 AM kline: Red_Tide: what is it you read?
01:37 AM kline: like, what document
01:37 AM kline: (iirc its to do with addressing)
05:21 AM twnqx` is now known as twnqx
11:19 AM JanC is now known as Guest10290
11:19 AM JanC_ is now known as JanC
12:15 PM snooky: hi all
12:16 PM nohit: hi
01:18 PM landau: hello, I have a C source code with some #ifdef and #ifndef statements in different .c files. How to tell make to define the variable for all files? Thanks
01:20 PM twnqx: you add -Dyourdefine to your CFLAGS
01:20 PM landau: I tried and I get a F_CPU define error
01:20 PM twnqx: ceck your makefile if it already sets CFLAGS somewhere
01:21 PM landau: yes it does
01:21 PM twnqx: you would be overwriting the original, so you can use CFLAGS+=yours
01:21 PM twnqx: or add it on the same line as the first onces
01:21 PM twnqx: ones*
01:21 PM landau: do I need -D >
01:21 PM landau: do I need -D ?
01:22 PM twnqx: the parameters from the CFLAGS varaiables are given to your C compiler
01:22 PM landau: yes
01:23 PM twnqx: -Dyourdefine[=yourvalue] tells the C compiler to assume the same as a #define, just from command line
01:23 PM twnqx: so yes, you'll need that, you can repeat it for everything you want to define
01:23 PM landau: ok let me try that
01:23 PM landau: make CFLAGS+=-DENABLE_ANALOG_IN
01:23 PM landau: I used that but I get an F_CPU error
01:23 PM twnqx: if you are using gnu make, that should work
01:24 PM landau: error: 'F_CPU' undeclared (first use in this function)
01:24 PM twnqx: no, you have to add this to youe makefile, sorry
01:24 PM twnqx: not the make parameters
01:24 PM landau: you mean CFLAGS+=-DENABLE_ANALOG_IN
01:24 PM landau: ?
01:25 PM twnqx: yes, you have to write it into the makefile, after the original definition
01:25 PM landau: ok it works! is there a way to have it directly from the command line?
01:25 PM twnqx: if you want to use parameters to make, it gets more difficult, but it is possible
01:26 PM twnqx: you can only have it indirectly, by having it conditionally in make
01:26 PM twnqx: in the makefile*
01:26 PM landau: mmmm do you if there is a tutorial for that?
01:27 PM twnqx: i am personally rarely using tutorials but just the documentation, i am afraid. let me quickly look up that part
01:27 PM nohit: its easy
01:28 PM twnqx: https://www.gnu.org/software/make/manual/make.html#Conditionals this would be the specific part
01:29 PM landau: ok
01:30 PM landau: so this should work with make -DMY_VAR
01:30 PM landau: right?
01:31 PM twnqx: it would be different
01:32 PM twnqx: make MYVAR=MYVALUE, then then you could e.g. add CFLAGS+=-D$(MYVAR) to your Makefile
01:32 PM landau: ok
01:33 PM twnqx: or you could use some more elaborate schemes, e.g. protecting against errors if you do not add anything
01:35 PM landau: ok
01:38 PM nohit: i would use the second method/answer here https://stackoverflow.com/questions/9052792/how-to-pass-macro-definition-from-make-command-line-arguments-d-to-c-source
01:42 PM landau: ok
01:42 PM landau: I will try both! thanks guys!
05:45 PM day_ is now known as day
11:33 PM day_ is now known as day