#avr Logs

Dec 17 2017

#avr Calendar

01:47 AM nuxil: "LeoNerd> twnqx: Sadly I don't think the C preprocessor is powerful enough to expand SetBits(PB1, PB3, PB6, PORTB); correctly"
01:50 AM nuxil: did you missout of jartza's macros ? https://gist.github.com/Jartza/56d006504316ef5fe5a3db1b3e438ca9
01:50 AM nuxil: *of - on
01:50 AM nuxil: BITS_SET(PORT, PB3, PB5, PB7) :)
01:50 AM rue_shop3: iirc jartza said it didnt work anymore, I didn't check...
01:51 AM rue_shop3: does it still work?
01:51 AM rue_shop3: if nothing else, I'm glad I have you lot thinking about it
01:57 AM MrMobius: what are you trying to expand it to?
01:59 AM MrMobius: I got frustrated with macros once and wrote my own preprocessor. If it's just a hobby project other people won't need to compile you can do that. Nothing special about the preprocessor that comes with C.
02:00 AM rue_shop3: simple macros can do a lot for code
03:01 AM polprog: i may as well add my 2 cents
03:01 AM polprog: i agree with LeoNerd that sbi and cbi macros work only on one bit and that's not useful in most cases
03:02 AM polprog: also for DDR registers in particular i like to just write a binary constant cos it's simple enough. so DDRB = 0b00001111; or even sometimes when i use a whole port as output i just write DDRB = 0xFF:
03:07 AM polprog: DDRC = (OUTPUT << PC0 | OUTPUT << PC1 |OUTPUT << PC2 |OUTPUT << PC3 |OUTPUT << PC4 |OUTPUT << PC5 );
03:07 AM polprog: this is very clear too
03:08 AM polprog: this is from "Rue's "is it alive" program for avr processors", version 4x7 segment multiplexing
03:49 AM rue_shop3: I find that 90% of people are only setting and clearing 1 bit at a time,
03:50 AM rue_shop3: to that effect, I'v never flipped out about someone writing code that does more than one bit at a time
03:50 AM rue_shop3: all the flipouts I'v had are cause of people not using a macro for setting and clearing 1 bit
03:53 AM polprog: sounds reasonable
04:21 AM nuxil: rue_shop3, he said that they didnt work? i havent tested them,,
04:22 AM nuxil: quote from yesterday, "<Jartza> I've used those macros for long time with avr, you can give meaningful names to pins and use them simply"
04:22 AM rue_shop3: he said they made a change and it broke, would you be willing to test?
04:22 AM nuxil: oh i missed that
04:23 AM nuxil: let me dink my morning coffee and i will test :p
05:01 AM rue_shop3: ok, I successfully told my reprap how large it really is without screwing it completely up
05:38 AM mmfood: how do people use custom libraries in C/AVR programming? Is there another way than having a 'lib' folder somewhere and cp the needed files to the working directory?
05:54 AM kvik: mmfood, you can have a lib folder somewhere and use -I -L and -l compiler flags to avoid having to cp anything. if you use a Makefile then there are IDIR, LDIR, LIBS, etc. that make this much easier to maintain.
05:55 AM kvik: for managing the lib folder itself you would use git and perhaps git submodules
05:56 AM kvik: there is also https://github.com/clibs/clib
06:01 AM nuxil: so rue_shop3 .. did Jartza really say that his macros where broke? i tried to look in the log. could not see he said that.
06:01 AM nuxil: these macros. https://gist.github.com/Jartza/56d006504316ef5fe5a3db1b3e438ca9 i tested using a simple test.
06:01 AM nuxil: https://pastebin.com/B7h7V6xW
06:01 AM mmfood: so would I just add -L/-l "~/clibraries/" to the compiler command?
06:01 AM nuxil: same output on pins using both metod
06:01 AM nuxil: so the macros are working
06:04 AM rue_shop3: cool
06:04 AM nuxil: did a test on my atiny85 :)
06:05 AM kvik: mmfood, suppose some eeprom lib is in ~/lib/eeprom with headers in ~/lib/eeprom/include and the library binary named libeeprom.a then you would do avr-gcc -o prog -I~/lib/eeprom/include -L~/lib/eeprom -leeprom prog.c
06:05 AM nuxil: mmfood, take a look at the make file for Tinytune.
06:05 AM nuxil: https://github.com/blakelivingston/avr_tinytune/blob/master/tinytune_test/Makefile
06:06 AM mmfood: rue_shop3: nice, useful macros!
06:07 AM nuxil: rue_shop3, i think you got confused. it was LeoNerd that said that he was unsure that setting multiple bits worked.
06:07 AM mmfood: kvik: ok
06:07 AM mmfood: kvik: what is "-leeprom"?
06:08 AM kvik: it's a linker flag that tells the linker to look in all the directories specified by -L for the binary named lib*.a where * is e.g. eeprom
06:09 AM mmfood: kvik: ok, thanks!
06:10 AM nuxil: rue_shop3, now.. your turn.. see if Jartza's SET_XYZ macros gets converted to sbi & cli instructions :p
06:13 AM kvik: mmfood, read up on those flags in the manual and elsewhere, it's handy to know. but I would suggest using a Makefile instead of typing them by hand or whatever
06:13 AM mmfood: kvik: yes, I am using a (simple) makefile
06:13 AM nuxil: o.O wtf...
06:13 AM nuxil: you typing it manualy ?
06:13 AM nuxil: nm
06:14 AM nuxil: i found that tinytune makefile to be a nice template to use.
06:16 AM mmfood: I have also a mapping of F9 to write the file I am working on and execute that makefile from within vim. So I have a basic but very neat setup for an IDE now with vim and tmux :)
06:18 AM kvik: mmfood, do you know about :make vim command?
06:23 AM mmfood: kvik: I know it exists and it is the command I have mapped but I don't know much else
06:24 AM kvik: mmfood, well the main advantage is the quickfix list it builds when running make, it parses the error messages from the compiler and allows you to jump to errors just like in some IDE.
06:24 AM kvik: type :copen and then navigate it with :cnext :cprev
06:25 AM kvik: you can also go into the quickfix window and press enter on the error to navigate
06:25 AM kvik: very nice stuff
06:27 AM mmfood: kvik: yes, it is quite handy :)
06:30 AM mmfood: I actually forgot about the quickfix window since I have a couple of <cr> in the mapping so that I don't have to view the output every time I compile/program. I should really figure out a good manner of bringing up the window in a more useful way though. As it is now it just pops up in a small part of one of my splits. I guess a new tab would be better or something like that
06:34 AM kvik: map :tab copen to something
06:35 AM mmfood: kvik: ah, that worked. Tried tabnew but that obviously just created a file called copen ><
06:36 AM kvik: I like the small window and hate tabs
06:39 AM kvik: you could also have a mapping that resizes the qf window after copening it to some size that you like, or have an autocmd that does it, or there may be a setting that I don't know of
06:43 AM mmfood: kvik: mapped <leader><f9> to :tab copen<cr> and <leader><f10> to :cclose<cr>, I quite like it :)
06:46 AM kvik: I map ,co ,cq to open and close qf window and ,cn ,cp to navigate really fast, never liked reaching for the funciton keys
06:46 AM mmfood: kvik: is , your <leader>?
06:47 AM kvik: yes
06:48 AM kvik: it makes for a great leader except it interferes with f and t command to search for characters in line. when using those the ; takes you to the next occurence and , to previous so if you use , for a leader it has a delay before it works.
06:48 AM mmfood: kvik: ok, I use space
06:48 AM mmfood: it is not used for much else, and it is right there :)
06:49 AM kvik: yea, space is nice but I got used to , and it's painful to try to switch :)
07:16 AM polprog: how would a gcc invocation look like to compile libeeprom.a from the example you gave, kvik ?
07:16 AM polprog: suppose im in ~/lib/eeprom/
07:28 AM kvik: you would first compile the libeeprom.c into libeeprom.o with avr-gcc -c libeeprom.c and then create an archive with ar rcs libeeprom.a libeeprom.o
07:28 AM kvik: polprog^
07:29 AM kvik: you would of course need to use avr-ar instead of system ar, which may work but also may not
07:30 AM LeoNerd: Why do you want a .a for avr code?
07:30 AM LeoNerd: AVRs are tiny as compared the development workstation you're on. What I do is just compile all the .c files directly into the final target in one go
07:31 AM LeoNerd: For shared library stuff I just `ln -s` the .c files - uart.c, spi.c, etc...
07:34 AM kvik: LeoNerd, we were talking about reusing often used custom libraries so I gave the suggestion of keeping libraries in some place and linking when needed. for tiny projects having all the code in a single folder is just fine but very soon becomes a cp(1) pain
07:34 AM LeoNerd: Yes I use symlinks instead of cp
07:34 AM LeoNerd: That way it shares the code, and updates and fixes to it remain shared
07:35 AM LeoNerd: Plus it means there's no two-stage process of building the support library and then the application. I literally build *everything* in one step, library and all
07:35 AM LeoNerd: Any edits to e.g. the underlying platform uart.c will be instantly reflected in any application that I 'make'
07:36 AM LeoNerd: I know it's quite different to how desktop or big-server software tends to work, but I find that it's actually quite nice and convenient for the size of program typically running on an AVR MCU
07:36 AM kvik: depends on what you like, I like having the same build philosophy for AVR as I do for UNIX stuff. I don't like to make a difference just because AVR are small
07:37 AM kvik: ln -s does sound okayish however :)
08:02 AM Santh_ is now known as Santh
09:05 AM mmfood: bad idea to have a flag in the ISR which is set when button was pressed and then check and clear it in main?
09:07 AM Tom_L: declare the flag volatile
09:07 AM Tom_L: and you may have to wait longer than you want to check it before it changes again
09:07 AM LeoNerd: mmfood: that's a typical interrupt idea in fact
09:08 AM Tom_L: but if not then it's fine
09:08 AM LeoNerd: Usually what I do in ISRs is simply mark a scheduler task as runnable and return, then my main loop will execute it
09:08 AM Tom_L: the idea of ISR is to get in and get out
09:08 AM LeoNerd: That helps with things like sharing I²C periperhal among multiple tasks which might want it, so they don't collide
09:09 AM Tom_L: then priority becomes part of a preemptive scheduler
09:10 AM Tom_L: this Emergency stop button is far more important than a coolant button
09:11 AM Tom_L: bad example anyway because the EStop shouldn't be in software anyway
09:12 AM * LeoNerd was about to say :)
09:12 AM Tom_L: just to portray the urgency of the situation :)
09:14 AM mmfood: allright, thanks!
09:14 AM Tom_L: if you don't declare it volatile it won't get updated
09:15 AM Tom_L: or re'read
09:15 AM * mmfood just realised that
09:17 AM Tom_L: IRQ is like the UPS guy that rings your door bell. By the time you answer the door, he's long gone ringing another one
11:06 AM nuxil: a friend of mine and i have this thing where we send each other weird stuff we find on youtube. usaly weird 70-80 music.
11:06 AM nuxil: he just sent me this. https://www.youtube.com/watch?v=TLnycVa20ts and now i cant get it out of my head :p
11:07 AM nuxil: some bitshifting going on in that video :p
11:08 AM Tom_L: well don't polute the rest of us :=)
11:08 AM nuxil: haha.
11:13 AM nuxil: is everyone digging da pop music now :p
11:14 AM Tom_L: meh
12:59 PM [1]MrMobius is now known as MrMobius
01:06 PM Neomex: hey i have this programmer: https://cdn.instructables.com/FD9/A5T4/HJKBYIPH/FD9A5T4HJKBYIPH.MEDIUM.jpg
01:06 PM Neomex: but i cant seem to find any guides on making custom board for atmega8
01:06 PM nuxil: looks like its just a usb to spi converter.
01:08 PM nuxil: Neomex, what do you need to know ? you got the scl, mosi, miso you need to programm a chip.
01:10 PM Neomex: havent played around with it for a while, from what i remember i had to setup a breadboard in some way to program atmega from usbasp
01:10 PM nuxil: yea
01:16 PM nuxil: idk but something like. avrdude -p mega8 -P usb -c usbasp bla bla also check the datasheet for which pin is sclk, mosi,miso.
01:23 PM nuxil: so. its really simple.just conect the mosi pin from the chip to the mosi input on your usb header. miso to miso, sclk to sclk and your reset pin.
01:44 PM polprog: kvik: thanks very much
04:14 PM polprog: goodnight
04:20 PM Emil: Neomex: https://emil.fi/avr
04:25 PM nuxil: Emil, to the rescue :D
04:57 PM rue_shop3: Emil, ah, it dosn't accept ssh3, and my browser dosn't have anything else
05:08 PM Neomex: Emil: you dont need to connect ground on 22?
05:14 PM nuxil: Neomex, always ground stuff :p
05:14 PM Neomex: it has two grounds though
05:14 PM Neomex: pin 8 and 22
05:15 PM nuxil: either should work
05:15 PM nuxil: bur to be sure, link them together
05:15 PM cehteh: on avr's you have to connect all GND's .. unless the datasheet says otherwise
05:16 PM nuxil: avcc should also be connected to vcc iirc unless youre using the adc or something.
05:16 PM cehteh: yes, same there connect all VCC's .. AVCC via filter when you want to use th analog stuff
05:18 PM Neomex: so link VCC with AVCC?
05:19 PM nuxil: read the datasheet :p
05:20 PM nuxil: in my atmega324p datasheet it says. ... It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter.
05:20 PM nuxil: guess the same goes for atmega8
05:23 PM Neomex: by 'externally connected' they mean connected by me? :p
05:25 PM nuxil: dont think the chip has arms to do by itself
05:26 PM Neomex: itd be more expensive if it had
05:27 PM nuxil: nah. seems like everything on ebay from china is like 10bucks :p
05:29 PM nuxil: Neomex, well go in the lab and start developing shaps hifing metal,/memory metal that you can use as pins. then figure out the voltage needed to generate the arm movements :p
05:30 PM nuxil: would be epic to see a chip walk on a flat conducting surface :p
05:30 PM Neomex: how am i supposed to program avr controlling the arms if i need arm to program avr?
05:30 PM Neomex: catch 22
05:31 PM nuxil: :\
05:33 PM Emil: cehteh: buulllshit
05:33 PM Emil: of course it's good design to connect both grounds
05:33 PM Emil: but they are internally connected anyways
05:35 PM Emil: nuxil: if you btw have any improvements or criticism on the tutorial, do say
05:51 PM nuxil: Emil, hmm. . the only thing that came to my mind was a simple diagram of a interface between 3.3v to 5v for thouse who use 3.3v. like raspberry users.
05:51 PM nuxil: like this, https://gyazo.com/b7c94d610f966b2261f53a98be5e93ea
05:51 PM nuxil: but in ascii :p
05:51 PM nuxil: ascii art style :)
05:52 PM nuxil: btw. thats is a working cuircet.
05:53 PM nuxil: *circuit
05:55 PM nuxil: maybe not needed. chip will get programmed at 3.3v
05:58 PM nuxil: perhaps a simple makefile?
06:00 PM nuxil: or is that out of the scope of of the tut ?
06:00 PM cehteh: Emil: there are chips around where gnd's are not connected or at least a single gnd cant sink enough current for every function
06:01 PM cehteh: dunno if that counts on AVR's but we had people in the past who had problems with only one gnd connected iirc
06:12 PM Neomex: any idea whats up with that? tried installing drivers
06:12 PM Neomex: https://pastebin.com/U7u9hV4p
06:13 PM Neomex: i have usbasp v2.0 from Lcsoft Studio
06:13 PM nuxil: is the port correct ?
06:15 PM nuxil: maybe it needs to be COM ? like com0 or com1 etc. . no idea how to do this stuff on windows :p
06:16 PM Neomex: tried with and without specyfying
06:21 PM nuxil: sure its the right programmer spesified? avrdude -c-help
06:21 PM nuxil: take a look
06:22 PM nuxil: usbasp-clone ?
06:28 PM Neomex: driver issue, works with different one
06:32 PM nuxil: :)
06:33 PM nuxil: try ther one the didnt work in a different usb port :p
07:02 PM Neomex: it is alive!
07:02 PM Neomex: buahahaha
07:02 PM Neomex: time to sleep
07:07 PM Neomex: took me only 4 more hours than expected
07:31 PM tiefbl300: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ https://www.youtube.com/watch?v=--jYqzJErTI LRH IS LIVE NOW!! CALL 415-349-5666 #LRH EFNETotqplzli: The_CooIest iSaul LeoNerd alx741 chupas lexAngeles RandomJamofJar KungFunk thardin spillere Aleks mmfood c-log Apocx vishwin atk kc2uez kl1n3 kline SebastianFlyte zopsi troyt JoeLlama Moarc sunri5e maqr proteus-guy kvik d
07:31 PM tiefbl300: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ https://www.youtube.com/watch?v=--jYqzJErTI LRH IS LIVE NOW!! CALL 415-349-5666 #LRH EFNETclvet: Frans-Willem troyt kc2uez dsalychev2 wpo spybert mmfood Moarc Apocx lexAngeles `z kline osteri iSaul grog dan3wik KungFunk Xark Casper maqr grafi_ kpo spillere SebastianFlyte alx741 kvik lemm1ngs impulse Aleks c-lo
07:31 PM tiefbl300: ▄▄▄▄▄▄▄▄▄▄ https://www.youtube.com/watch?v=--jYqzJErTI LRH IS LIVE NOW!! CALL 415-349-5666 #LRH EFNETbqazawlud: atk w0bni sunri5e `z samuelAA impulse RandomJamofJar daey lexAngeles lemm1ngs dan3wik spillere kvik proteus-guy Xark spybert JoeLlama c-log HighInBC sabor grafi_ Moarc c4017_ Snert vishwin jadew Frans-Willem kline dsalychev2 kl1n3 captain_morgan KungFunk thardin Aleks comptroller polprog C
07:31 PM tiefbl300: ▄▄▄▄▄▄▄▄▄▄ https://www.youtube.com/watch?v=--jYqzJErTI LRH IS LIVE NOW!! CALL 415-349-5666 #LRH EFNETiegle: grafi_ Snert c-log alx741 dan3wik atk proteusguy iSaul comptroller LeoNerd Tom_shop kl1n3 impulse grog dsalychev2 kvik proteus-guy JoeLlama MrMobius Aleks captain_morgan Moarc zopsi Xark Apocx maqr osteri sunri5e Casper lexAngeles twnqx kline RandomJamofJar chupas KungFunk vishwin troyt The_Co
07:31 PM tiefbl300: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ https://www.youtube.com/watch?v=--jYqzJErTI LRH IS LIVE NOW!! CALL 415-349-5666 #LRH EFNETfycpzmlna: chupas `z JoeLlama Frans-Willem HighInBC grafi_ Tom_shop KungFunk Xark impulse LeoNerd dsalychev2 twnqx c4017_ Apocx kvik spillere alx741 SebastianFlyte atk Moarc grog troyt The_CooIest c-lo
07:31 PM nuxil: rue_shop3,
07:31 PM tiefbl300: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ https://www.youtube.com/watch?v=--jYqzJErTI LRH IS LIVE NOW!! CALL 415-349-5666 #LRH EFNETpvckioonnq: kl1n3 mmfood dan3wik twnqx chupas sunri5e Xark kc2uez wpo JoeLlama spybert lexAngeles sabor LeoNerd jadew kpo spillere vishwin SebastianFlyte `z Snert KungFunk grog troyt MrMobius kline lem
07:31 PM tiefbl300: ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ https://www.youtube.com/watch?v=--jYqzJErTI LRH IS LIVE NOW!! CALL 415-349-5666 #LRH EFNETlpshelfq: spybert Aleks The_CooIest atk impulse lexAngeles kl1n3 grog LeoNerd zopsi c4017_ RandomJamofJar alx741 JoeLlama daey jadew grafi_ lemm1ngs sunri5e MrMobius chupas troyt thardin sabor Snert Frans-Willem Casper dsalychev2 polprog pro
07:58 PM -!- #avr mode set to +o by ChanServ
07:59 PM rue_mohr: grr
07:59 PM rue_mohr: those messages are compliments of Rucas, who hates freenode
08:03 PM -!- #avr mode set to +o by ChanServ
08:03 PM learath: Rucas?
08:04 PM rue_bed: yup
08:15 PM Casper: rue_mohr: any back story on that?
08:16 PM learath: Casper: maybe freenode stole his dog and ran away with his truck?
08:16 PM Casper: maybe
08:20 PM nuxil: some people never grow up and have a grudge against everybody and everything.
08:24 PM learath: Sure, it just sounded like there was a story.
08:36 PM nuxil: man. why are there like a trillion versions of the stm32 nucleo boards.
08:37 PM nuxil: im ordering some new stuff. and was thinking about getting a nucleo while im at it.
08:40 PM nuxil: this one a ok one ? https://www.elfadistrelec.no/Web/Downloads/_t/ds/NUCLEO-xxxRx_eng_tds.pdf
08:41 PM nuxil: arg.. * STM32F446RE
08:41 PM nuxil: NUCLEO-F446RE, ST
11:07 PM day__ is now known as daey
11:33 PM RandomJamofJar is now known as Smuckerz