#avr Logs

Oct 08 2017

#avr Calendar

12:09 AM day is now known as daey
07:45 AM Lambda_Aurigae: rue_house, you missed one...ToggleBit()
08:02 AM Lambda_Aurigae: http://www.kjmagnetics.com/blog.asp?p=electromagnetic-levitation
08:13 AM Emil: https://github.com/skeeto/gap-buffer-animator
08:13 AM Emil: Did I understand this right: you can make gif animations just by writing .ppm images in series?
08:17 AM thardin: me and a friend used to make animations by concatenatibg .dib files
08:18 AM thardin: so maybe? but ppm is text based i think, so probably wont work
08:46 AM Emil: no
08:46 AM Emil: ppm is ascii header + binary data
09:03 AM thardin: right. well they don't start with GIF87a so
09:41 AM carabia: Lambda_Aurigae: tl;dr, the frog levitation was much funnier
09:52 AM Emil: carabia: did you go to a uni? Which one?
09:53 AM carabia: guess
10:02 AM Emil: Oulu
11:14 AM rue_house: Lambda_Aurigae, new style or old style?
11:15 AM rue_house: #define SetBit(BIT, PORT) (PORT |= (1<<BIT))
11:15 AM rue_house: #define ClearBit(BIT, PORT) (PORT &= ~(1<<BIT))
11:22 AM Lambda_Aurigae: you have set and clear but not toggle.
11:22 AM rue_house: Lambda_Aurigae, new style or old style?
11:23 AM Lambda_Aurigae: no clue what the difference is.
11:23 AM Lambda_Aurigae: was just a comment that you had both set and clear there but no toggle.
11:23 AM rue_bed: writing to the PIN register
11:24 AM rue_bed: or read-modify-write
11:24 AM Lambda_Aurigae: guessing a toggle would need a read/mod/write process.
11:24 AM rue_bed: nope
11:25 AM rue_bed: on the new ones, you can write to the PIN register and the hardware will toggle the bit
11:25 AM Lambda_Aurigae: aahh.
11:25 AM Lambda_Aurigae: guess I missed that part.
11:25 AM Lambda_Aurigae: how new?
11:25 AM Lambda_Aurigae: atmegn1284p and newer or the new new series?
11:26 AM rue_bed: hmm, typically if its a chip with pin change on EVERY pin, its the new core
11:26 AM Lambda_Aurigae: ok..so atmega1284p qualifies.
11:27 AM Lambda_Aurigae: AVR5 core or something like that?
11:28 AM rue_bed: not completely sure
11:46 AM thardin: Emil: I got it to work!
11:46 AM thardin: latest avr-gcc that is
11:50 AM Lambda_Aurigae: now compile the latest xc-32
11:51 AM Lambda_Aurigae: gcc based compiler for pic32
11:53 AM thardin: nah
11:53 AM thardin: hrm, it's still pointlessly pushing things
12:01 PM thardin: I'd expect an empty ISR to generate just a single reti instruction and nothing more
12:22 PM antto: xmegas have PORT.OUTSET, PORT.OUTCLR, and PORT.OUTTGL
12:23 PM antto: muchos nais
12:24 PM antto: PORTC.OUTTGL = 0x0F; // toggle pins 0 to 3
12:24 PM polprog: wow
12:49 PM Lambda_Aurigae: thardin, you have to use naked ISRs for that.
01:01 PM Emil: thardin: gj
01:02 PM Emil: thardin: when I did that for the raspberry pi 3 it took ages
01:05 PM Emil: The annoying thing is that it still doesnt suppory 328pb out of the boz
01:05 PM Emil: you have to manually add a patch
01:11 PM thardin: Lambda_Aurigae: so I suspect. but it just seems like something gcc ought to figure out
01:11 PM thardin: Emil: yeah, I read that
01:11 PM thardin: "patch welcome" as they say :)
01:24 PM Lambda_Aurigae: that's how it's figured out.
02:10 PM Emil: Hey
02:10 PM Emil: There's this cool thing
02:10 PM Emil: alloca
02:10 PM Emil: I wonder if that works on avrs >:D
02:12 PM thardin: uhm, you mean if avr has a stack?
02:12 PM thardin: I should think so
02:27 PM carabia: Emil: TKK, before all of your aalto-hipster-stuff
02:28 PM Emil: carabia: EST?
02:59 PM Emil: What does lo8() mean?
02:59 PM Emil: https://sourceware.org/binutils/docs-2.26/as/AVR_002dModifiers.html
02:59 PM Emil: What's 8 bit relocatable expression.
03:04 PM polprog: takes the lower byte of a 16 byte integer
03:05 PM polprog: ive seen it as an assembly pseudoop
03:05 PM polprog: like when you have tu load a 16 bit constant, you use one ldi with lo8() and one ldi with hi8()
03:09 PM Emil: https://godbolt.org/g/MQkrEZ
03:09 PM Emil: polprog: the usecase made no sense to me
03:09 PM polprog: neither it does to me.
03:09 PM polprog: hey cool, online avr copiler explorer!
03:10 PM Emil: Can you help me understand how the fuck does a work here
03:10 PM Emil: I don't see it defined anywhere
03:11 PM polprog: i see it defined in line 4
03:11 PM Emil: yes
03:11 PM Emil: but look at the asm
03:11 PM Emil: I wrote that C myself
03:12 PM polprog: you mean lds r24,a for example?
03:12 PM Emil: yeah
03:12 PM polprog: the syntax for LDS is register, const adress
03:13 PM polprog: so i guess the linker or whatever digests the code next will decide where tin SRAM to put a and replace the symbol with an actual adress
03:13 PM polprog: let me compile that and see
03:13 PM Emil: Hmm, if you disable .text hiding
03:13 PM Emil: a: fills with things
03:13 PM Emil: https://emil.fi/jako/kuvat/2017-10-08_22-42-10_svFzLmAS.png
03:13 PM Emil: there's also .global a
03:13 PM Emil: twice :D
03:13 PM Emil: wtf
03:14 PM polprog: wtf
03:14 PM Emil: https://emil.fi/jako/kuvat/2017-10-08_22-42-38_5vlZzzCf.png
03:14 PM polprog: let me objdump my out file
03:14 PM Emil: https://godbolt.org/g/B8w8wQ
03:14 PM polprog: yes, here it is
03:15 PM polprog: https://puu.sh/xTehX/a5e28b34d7.png
03:15 PM Emil: matey
03:15 PM Emil: did you not use -Os? :D
03:15 PM polprog: no i just typed the simplest invocation
03:15 PM polprog: why would i do that to test
03:15 PM polprog: it's volatile so it will be always savet to mem
03:16 PM polprog: saved*
03:16 PM Emil: Because withou any optimisations the code is absolutely horrible and not representative of the real situatiion
03:16 PM polprog: ok, ill -Os
03:17 PM polprog: full listing: https://paste.debian.net/989672/
03:18 PM polprog: your isr is at 0x7c and theres some vector_2 interrupt which does stuff
03:18 PM Emil: why didn't ISR_NAKED have to push stack btw?
03:19 PM Emil: stack address*
03:19 PM polprog: maybe cos it's naked
03:19 PM Emil: yeah but
03:20 PM Emil: https://emil.fi/jako/kuvat/2017-10-08_22-48-49_33pxYFha.png
03:20 PM Emil: sorry
03:21 PM Emil: I meant instruction pointer
03:21 PM Emil: not stack pointer
03:22 PM polprog: maybe the avr does that itself
03:22 PM polprog: that's what the reti operation would suggest
03:22 PM polprog: "do the stuff that's needed to return from interrupt"
03:22 PM Emil: Hmm
03:23 PM Emil: It would have to save the instruction pointer
03:23 PM Emil: and then on reti swap the instruction pointer
03:24 PM Emil: well, move instruction pointer to behind the scenes register and move behind the scenes register to instruction pointer
03:24 PM polprog: they say that the status register must be taken care of by the programmer but nothing about the program counter
03:24 PM Emil: yeah
03:25 PM Emil: https://emil.fi/jako/kuvat/2017-10-08_22-53-51_UttTMt3Y.png
03:25 PM Emil: http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_reti.html
03:26 PM polprog: brb
03:29 PM polprog: yeah so it looks like the avr does that by itself
03:31 PM Emil: yeah but
03:31 PM Emil: wtf
03:31 PM Emil: does the avr itself push to stack
03:31 PM Emil: what if I mangle those :D
03:31 PM Emil: Hmmmmm
03:31 PM Emil: I should test this
03:32 PM Emil: what if I push some other address
03:32 PM Emil: does reti then result in a jump to a "wrong" address
03:32 PM Emil: Even if SREG is not modified
03:33 PM polprog: yes, got it
03:33 PM polprog: During this 4-clock cycle period, the Program Counter is pushed onto the
03:33 PM polprog: Stack. The Vector is normally a jump to the interrupt routine, and this jump takes three clock
03:33 PM polprog: cycles
03:33 PM polprog: it's in the m8 datasheet on page 16
03:34 PM Emil: interesting
03:35 PM Emil: so a) you have to have enough space on stack to use interrupts and b) you can fuck around with it
03:35 PM Emil: if you push something else to stack
03:35 PM polprog: in assembly you can fuck around everything
03:36 PM polprog: you can put a nop in the interrupt vector adress and watch it execute the jump in the next adress :P
03:36 PM Emil: But it's annoying that this is not mentioned in the instruction manual
03:36 PM polprog: true dat
03:37 PM Emil: whatcha mean with that above btw?
03:37 PM Emil: put a nop into the vector table?
03:37 PM polprog: yeah
03:37 PM polprog: and watch the thing trip and crash
03:37 PM Emil: but the vector table is a set off addresses
03:37 PM Emil: s/off/of
03:38 PM polprog: is it?
03:38 PM Emil: yah
03:38 PM polprog: i see jumps in the vector table
03:38 PM polprog: meh
03:38 PM Emil: you can also manually edit it :D
03:38 PM polprog: im mening, in that paste
03:38 PM polprog: if you overwrite that table of JMPs
03:39 PM polprog: you can cause pretty big mayhem
03:39 PM polprog: or you can write a bootloader that does that
03:39 PM Emil: oh
03:39 PM Emil: it was instructions
03:39 PM Emil: instructions with associated data, not just data
03:40 PM Emil: but yeah
03:40 PM Emil: messing with the vector table is fun
03:40 PM polprog: another interesting thing. look what happens when an interrupt without isr defined executes. it jups to <__bad_interrupt>, that jumps to <__vectors> and that jumps to <__ctors_end> starting the program over
03:41 PM polprog: so if you happen to enable some interrupt and forget to define an isr...
03:41 PM polprog: instant reset?
03:41 PM Emil: yes
03:41 PM Emil: but that's well documented feature
03:41 PM polprog: heh
03:42 PM Emil: polprog: you know what's also interesting
03:42 PM Emil: you can hijack that bad_interrupt
03:42 PM polprog: yeah
03:43 PM Emil: https://emil.fi/jako/kuvat/2017-10-08_23-11-35_6BoZnzsh.png
03:43 PM Emil: I wish avrs supported execution from ram
03:43 PM Emil: That would be sweet as fuuck
03:43 PM polprog: ISR(BADISR_vect) { launch_nukes(); sleep(); }
03:43 PM polprog: yeah, that would be awesome
03:44 PM tpw_rules: then they wouldn't be single cycle
03:44 PM polprog: rams or roms
03:44 PM Emil: tpw_rules: not true
03:44 PM polprog: you could spaw EEPROMs :v
03:44 PM polprog: you can use a z80 or another bare CPU with it's compatible rams and roms
03:44 PM tpw_rules: z80s take like 17 cycles to do anything
03:45 PM polprog: never programmed one
03:45 PM Emil: I just want a repl asm simulator for avrs
03:45 PM polprog: repl asm?
03:45 PM Emil: yeah
03:45 PM Emil: assembly shell if you will
03:45 PM polprog: ah
03:45 PM polprog: well, if you ported, say CP/M
03:46 PM polprog: not sure if possible
03:46 PM polprog: then...
03:46 PM Emil: but say
03:46 PM Emil: lo8(4);
03:46 PM polprog: oh, it's done: http://spritesmods.com/?art=avrcpm
03:47 PM Emil: if we jmp back to the discussion before
03:47 PM polprog: shit this is serious geekery and nerdery. he plays ZORK on an avr
03:48 PM HighInBC: the z80 was a fine chip
03:48 PM tpw_rules: lies
03:48 PM polprog: looks like he emulates 8080
03:48 PM tpw_rules: 6502 for life
03:48 PM Emil: https://godbolt.org/g/hVqwfA
03:49 PM polprog: lo8 right?
03:49 PM Emil: yeah
03:50 PM polprog: try to compile it IRL and look at objdump
03:50 PM Emil: https://godbolt.org/g/xT6CQT
03:50 PM Emil: or here
03:50 PM Emil: in vector_1
03:51 PM polprog: http://www.atmel.com/webdoc/avrlibcreferencemanual/assembler_1ass_pseudoops.html
03:51 PM Emil: I mean I understand why it's optimising
03:51 PM Emil: but I don't understand why it's emitting lo8(4) when it could just say 4
03:51 PM polprog: i dont get it either
03:52 PM polprog: but you are looking at the direct compiler output
03:52 PM polprog: which goes through some stuff later
03:52 PM polprog: probably linker but before that the assembler itself
03:52 PM Emil: No
03:52 PM polprog: look at the eventual output
03:52 PM Emil: That's still an intermidiate step
03:52 PM Emil: hmm
03:53 PM Emil: How can I get it to do that here
03:53 PM polprog: you cant i think, just run objdump
03:53 PM polprog: in a terminal
03:53 PM polprog: are you in the uni lab? just curious
03:53 PM Emil: no
03:53 PM Emil: at home
03:53 PM Emil: why?
03:54 PM Emil: Also it's _our lab_, not uni lab ;)
03:54 PM Emil: our student run lab
03:54 PM polprog: im thinking why are you using that site instead of writing the code in an editor and compiling it
03:54 PM Emil: because I'm lazy :D
03:54 PM Emil: And fucking around
03:54 PM Emil: polprog: I have two avrs connected to my pine64 (an sbc)
03:55 PM polprog: that pine looks sweet
03:55 PM Emil: so I could at any point I have internet access write code, compile and flash two avrs
03:55 PM Emil: polprog: it's cheap, too
03:55 PM Emil: and it gets quite close to the 1Gbps
03:55 PM Emil: it's way better than a raspi imho
03:55 PM polprog: yeah, i guess
03:56 PM polprog: im playing with an old pentium so i could take a break and kick up a raspi server
03:56 PM polprog: :PP
03:58 PM polprog: it's harder to loose a huge PC than a small pcb
03:58 PM polprog: i had 3 raspis but i lost one
03:58 PM polprog: no idea where it is
03:58 PM Emil: https://emil.fi/jako/kuvat/photo5967363287333055382.jpg
03:58 PM Emil: Check out my high tech solution
03:58 PM polprog: wait to see mine
03:58 PM Emil: polprog: lolwat :D
03:58 PM Emil: how the fuck can you _lose_ a raspi :D
03:59 PM polprog: the solaris in quemu because i was bored: https://puu.sh/xSud3/b93ca14698.jpg
03:59 PM polprog: the afromentioned pentium server PC: https://puu.sh/xOiWz/ae599a307e.jpg
03:59 PM Emil: ewwww
03:59 PM polprog: qemu*
04:00 PM Emil: That's some old tech :D
04:00 PM Emil: You still have those windows stickers on that :D
04:00 PM polprog: and the raspis are in static bags in a drawer
04:00 PM polprog: one used to run a persisten irc session before i bought a vps
04:01 PM polprog: screenshot: https://puu.sh/xSbS0/52578208f3.png
04:04 PM Emil: why'dyoudothat
04:05 PM polprog: 1) i was bored, 2) it looks absolutely, as you say, kawaii, with CDE's blue-pink colors <3 http://picpaste.com/solaris4-fronODrB.png
04:05 PM tpw_rules: does picpaste.com only own one 56k modem
04:06 PM polprog: dunno, puush script didnt work for that one, so it's mine failover for uploading silly pics
04:06 PM polprog: maybe the admin is on the phone!
04:06 PM Emil: That does look pretty cute
04:07 PM polprog: i would put CDE on that pentium but it takes some work to compile it
04:07 PM polprog: so i went with icewm
04:07 PM Emil: CDE?
04:07 PM polprog: the DE you see on that pic
04:07 PM polprog: https://en.wikipedia.org/wiki/Common_Desktop_Environment
04:10 PM polprog: it's more aesthetic than windows 95
04:11 PM polprog: because it's prettier
04:13 PM Emil: That does give a retro hardon
04:14 PM polprog: and, from what iv'e heard it's still usable
04:54 PM Emil: https://www.youtube.com/watch?v=SAxQVx9X-DE
04:54 PM Emil: polprog:
04:54 PM Emil: for you
08:23 PM robinak is now known as robink
08:37 PM enh: hi
11:38 PM _ami_: nice, 2.2k R works well on USB D+ line of blue pill board. :) replaced R10 (10k) with 2.2k (which i salvaged from broken step up boost converters)