#avr Logs

Apr 20 2017

#avr Calendar

12:13 AM daey_ is now known as daey
01:09 AM daey_ is now known as daey
03:10 AM Emil: hmm.
04:30 AM daey_ is now known as daey
08:20 AM arij is now known as arij_work
09:32 AM Emil: hehe
10:08 AM Emil: So umm
10:09 AM polprog: i hope my lappy still works... otherwise i can do anything
10:11 AM Emil: cant?
10:11 AM Emil: Anycase, https://emil.fi/jako/kood/asciitable.c
10:12 AM polprog: yeah, cant do *
10:12 AM Emil: Got god damn tired of always looking it up online
10:12 AM Emil: I recommend aliasing it or placing it in bin
10:12 AM polprog: emil, it redirects to home for me
10:12 AM Emil: Anycase, https://emil.fi/jako/koodi/asciitable.c
10:12 AM Emil: missed a letter
10:13 AM Emil: Now there is a packagage called ascii in the debian (prolly all derivatives by extension, too)
10:13 AM Emil: but mine does colours :3
10:13 AM Emil: if you ask it to
10:13 AM polprog: ah so thats a linux code, not avr
10:13 AM Emil: yeah
10:13 AM * polprog thought why would an avr need such a piece of code
10:14 AM polprog: iirc theres a repo called rice which has some cool terminal programs
10:14 AM polprog: for true haxors who ping 127.0.0.1 and traceroute people
10:17 AM Emil: :DDD
10:17 AM Emil: I only strace and read the raw memory locations
10:18 AM polprog: classic https://youtu.be/SXmv8quf_xM
10:59 AM polprog: one thing bothers me
11:00 AM polprog: in the datasheet where i found the adresses for IO regs, there were two numbers, one in parentheses
11:00 AM polprog: what does that do?
11:01 AM Emil: picture?
11:02 AM NoHitWonder^: hopefully i'll finish my music player this weekend
11:02 AM NoHitWonder^: took some tools from work
11:03 AM polprog: http://www.atmel.com/images/doc8246.pdf page 255
11:04 AM NoHitWonder^: anyone here done wav file parsing?
11:05 AM Emil: NoHitWonder^: I read about it once
11:05 AM Emil: it's not too hard
11:06 AM NoHitWonder^: yeah
11:07 AM Emil: polprog: you can see they are all offset by a certain number
11:07 AM NoHitWonder^: well, at first im gonna try without parsing and use file with known sample rate
11:07 AM polprog: emil, thanks, im reading the DS now
11:08 AM Emil: http://www.avrfreaks.net/forum/assembler-newbie-cant-understand-io-address-offset
11:09 AM polprog: wait, its on the next page in the notes :D now i get it
11:10 AM Emil: Yeah :D
11:12 AM polprog: lol, on the raspi channel there was some guy refusing to learn ohms law trying to power some 100mA led
11:12 AM NoHitWonder^: Emil write me a wav file parser :D
11:12 AM NoHitWonder^: i'll buy you a beer some day
11:12 AM polprog: NoHitWonder^: convert to raw instead
11:12 AM NoHitWonder^: well, gotta hit the bus ->
11:14 AM Emil: hehe
11:28 AM polprog: so far my favourite directive is BRIE
11:34 AM polprog: hmm, #define doesnt work
11:35 AM Emil: hm?
11:36 AM polprog: on the top of the file i did '#define PORTD 0x12" and the compiler then spits "undefined reference to PORTD" on "out PORTD, r16"
11:43 AM Emil: How are you coding in asm?
11:44 AM Emil: polprog: try .equ PORTD = 0x12
11:46 AM polprog: Emil: thanks :D it worked, ".equ PORTD, 0x12"
11:47 AM polprog: the compiler wanted a comma
11:58 AM Emil: ah
12:13 PM polprog: hmm, on that same page there's the directive syntax, for example "LDI Rd, K", and next line is "LD Rd, X". what do K, X, etc mean there? i suppose Rd is the target reg.
12:13 PM polprog: is it some kind of a data type thing?
12:17 PM Emil: I think both are just numbers
12:17 PM polprog: ok
12:18 PM Emil: LDI and LD are different though so I bet they used different names to indicate that they aren't the same thing
12:18 PM Emil: I think in this case K is an actual konstant
12:18 PM Emil: and X is an address
12:18 PM Emil: Because LDI is load immediate and LD is load indirect
12:19 PM polprog: so i do like ld r1, r2 ?
12:19 PM polprog: copy one reg to another?
12:20 PM Emil: noooo
12:20 PM Emil: mate :D
12:20 PM polprog: load from a memory address to a reg?
12:20 PM Emil: http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_LD.html the manual is good
12:20 PM Emil: if you need to shuffle registers around use mov
12:23 PM polprog: oh, its in instruction set nomenclature
01:35 PM polprog: wow! it works: https://drive.google.com/file/d/0B7nrducTAtMTeWVFY3AzR3RrREE/view?usp=drivesdk
01:37 PM Emil: Nice job : )
01:37 PM Emil: Hmm, I should seriously look up avr asm
01:48 PM polprog: now lets make it conditional
01:49 PM NoHitWonder^: i made a driver for 4x4 keyboard with avr asm back in the day when i was studing electronics
01:49 PM Emil: Scanning or per pin?
01:49 PM NoHitWonder^: scanning
01:50 PM Emil: Well, you won 50% in pin count so that's okayt
01:50 PM Emil: but there's a local optimum where it's okay to use per pin :D
01:51 PM Emil: because of standardised pin packages
01:52 PM NoHitWonder^: yep
01:52 PM NoHitWonder^: need to go again ->
01:59 PM polprog: hmm. any good decompiler/visualizer? im not sure if i implemented a double loop correctly
02:01 PM polprog: hey, it works!
02:01 PM polprog: i should try to add controlable delays
02:02 PM kl0wn: what kidn of board is that you're using?
02:02 PM polprog: my own, for now a tiny4313 and 3 leds (2 of them not yet connected :D )
02:03 PM kl0wn: ahh
02:05 PM polprog: kl0wn: https://drive.google.com/file/d/0B7nrducTAtMTbFllYW44Zm5Rd0k/view?usp=sharing
02:09 PM kl0wn: ahh cool
02:10 PM kl0wn: would like to get into avr, not really sure where to start, just read random documents sometime :o)
02:21 PM Emil: kl0wn: https://emil.fi/avr
02:22 PM Emil: kl0wn: you can substitute the hardware section with an arduino/other board
02:39 PM polprog: any asm veteran can help me how to calculate the cycle count for loopA? http://wklej.org/id/3091535/
02:40 PM polprog: it blinks @ ~1Hz now
02:41 PM Emil: polprog: why you need a veteran for it?
02:41 PM Emil: avr's don't have pipelines so everything is quite deterministic
02:42 PM polprog: from my calcs it says around 50k cycles for the thing to execute
02:42 PM Emil: so you just look up the instructions and how long they take to eecute
02:42 PM polprog: doesnt make sense because the led blinks 1/sec
02:42 PM Emil: have you taken into account that not everything is 1 ccle
02:42 PM Emil: branches and jumps are two
02:42 PM polprog: yes, brne is 2 cycles if it jumps
02:45 PM Emil: umm
02:45 PM Emil: you have two brne loopAstart
02:45 PM Emil: oh it's just confusingly named
02:46 PM polprog: so, as it says in the DS the default clock is 1Mhz - 8mhz and ckdiv8 set
02:46 PM Emil: look at how _delay_ms and _delay_us are implemented
02:46 PM Emil: or even better
02:46 PM Emil: look at how _delay_loop_1 and 2 are implemented
02:47 PM Emil: personally I'd use timers
02:47 PM Emil: Better to ditch the busyloops instantly if you have already used them with C
02:47 PM Emil: And know and undestand why they are bad
02:47 PM polprog: yes, using timer interrupts wil be another, and better aproach
02:48 PM polprog: i never used such loops in c
02:48 PM Emil: polprog: you never used _delay_ms?
02:48 PM polprog: i always used _delay_ms
02:48 PM Emil: you don't need to use interrupts
02:48 PM Emil: you can just poll the flags also
02:48 PM polprog: or interrupts. i never used empty loops to delay
02:50 PM polprog: so in the next program i will use timers. now i wanna know how to properly calculate the amt of cycles for a given, looping routine
02:52 PM kl0wn: thanks for the link
02:54 PM polprog: kl0wn: for more adv stuff, look for Dean Camera's tutorials
03:08 PM Emil: kl0wn: np
03:09 PM Emil: polprog: mate, it is exactly like I said :D
03:09 PM Emil: just look at the instructions and how many cycles they take
03:09 PM Emil: waaaaaitasecond
03:10 PM Emil: ah nvm
03:10 PM Emil: the basic loop is ldi, dec, brne
03:11 PM Emil: brge*
03:12 PM Emil: or so on
03:14 PM polprog: brge
03:14 PM polprog: WAIT
03:14 PM polprog: forget what i said
03:15 PM polprog: the led is hooked up to PD2 so it's 8 times slower
03:15 PM polprog: everything makes sense now
03:15 PM polprog: i made a working assembly program. yes!
03:18 PM xentrac: congratulations!
03:18 PM polprog: i should solder the reamining 3 leds
03:19 PM polprog: or better prepare for school tomorrow and then solder
04:46 PM arij_work is now known as arij
05:13 PM polprog: is it possible/practical to split a bigger assembly code into separate files? any additional directives or its just linker's job to put that together?
05:16 PM * antto throws the third letter from the alphabet at polprog
05:17 PM Casper: polprog: it is possible, that's how big projects is done
05:17 PM Casper: you split by module
05:17 PM Casper: very usefull for easy code reuse
05:17 PM Casper: and to also help to maintain the code
05:18 PM Casper: have a problem with PWM? look at the pwm file
05:24 PM polprog: Casper: thanks :)
05:24 PM polprog: night o/
05:26 PM Casper: night? no!
05:27 PM Casper: it's only 17:58!
05:27 PM Casper: ... and still 1 hour of work...
05:31 PM Emil: 01:01