#avr Logs

Nov 03 2017

#avr Calendar

12:12 AM Ameisen: reminds me that I need to finish writing up the spec for my virtual cpu arch
01:07 AM day is now known as daey
01:13 AM toblorone: dumb question: do you know if openocd works with atmel's debugwire?
01:16 AM theBear: what you mean by work exactly ?
01:18 AM toblorone: theBear: uh, so like i said dumb question... but its my understanding the debugwire is just another on chip debugging protocol like jtag, right? Well I'm trying to get openocd to interface with it
01:18 AM toblorone: and i don't see any configuration option for debugwire with openocd
01:23 AM theBear: woops, i acronym'd wrong, ignore me
01:32 AM shifttymike is now known as Guest43378
04:41 AM nuxil: mornings.
04:44 AM nuxil: so im trying to move the pulling of the pins in my main loop to a isr . to see if the rotary encoders have been rotated.
04:45 AM nuxil: i wrote this simple test https://pastebin.com/gBbqhDQb however.
04:45 AM nuxil: when i rotate the knob. it just toggles between OCR0B = 192; and OCR0B = 64; . in both directions
04:45 AM nuxil: i set it to detect falling and rising edge. is this wrong ?
04:55 AM nuxil: my problem is that. rotating the switch makes if(cbits & (1 << PB0)) True no matter what direction im turning.
04:56 AM nuxil: so it will always evaluate the val = ( PINB & ( 1 << PB2 ) ) ? 1 : 0; and run that if else statement. hence toggle OCR0B between 192 and 64
04:56 AM nuxil: but how do i fix this :p
05:49 AM nuxil: never mind.. got it working.
05:51 AM nuxil: this was helpfull https://thewanderingengineer.com/2014/08/11/rotary-encoder-on-the-attiny85-part-2/ :D
06:39 AM polprog: good morning
06:39 AM polprog: finishing my assembly tutorial
06:40 AM Lambda_Aurigae: cover all the opcodes?
06:40 AM polprog: no
06:40 AM polprog: it's a beginner crash course
06:40 AM polprog: only the basic onces
06:40 AM polprog: ones*
06:41 AM Tom_L: like nop?
06:41 AM polprog: yeah
06:41 AM polprog: youll see
07:12 AM _ami_: polprog, cool.
07:12 AM _ami_: already published any?
07:13 AM polprog: yeah, on localhost
07:13 AM polprog: ;)
07:14 AM polprog: im trying to find a way to describe the calculation of a 3 stage delay loop in a way that an average arduino or c guy understands
07:15 AM polprog: on the other hand, that would be too long
07:15 AM polprog: the tutorial is about blinking a led not dela loops
07:15 AM polprog: ill just link the generator
07:17 AM polprog: delay*
07:24 AM cehteh: better use a timer
07:38 AM polprog: yes, indeed
09:15 AM Ameisen: I'm wondering if the 'Polly Loop Optimizer' would show any benefits for uarchs like AVR
09:15 AM Ameisen: it appears to be mainly designed for instruction/meemory scheduling for SIMD, so in that case, no
09:16 AM Ameisen: but wondering if it adds any value to general handling of loops
09:16 AM Ameisen: only appears to help parallel code though
11:59 AM polprog: http://polprog.net/blog/asm/
11:59 AM polprog: initial version
12:53 PM polprog: Emil: ^
01:20 PM Jartza: uhh
01:20 PM nuxil: verry nice
01:20 PM Jartza: I have gnu syntax
01:20 PM Jartza: hate*
01:20 PM Jartza: and the _SFR_IO_ADDR -macro
01:26 PM polprog: tbh i couldnt get tha tmacro to work so i used .equ and defined those io adresses :D
01:30 PM Jartza: also the loop makes no sense :(
01:30 PM Jartza: why not use 24-bit counter and single brne
01:31 PM Jartza: subi r18, 1; sbci r19, 0; sbci r20, 0; brne loop....
01:33 PM Jartza: with your loop, you could as well use 255 in r18 and r19
01:34 PM Jartza: oops. r19 and r20 I mean
01:37 PM Jartza: also if you want to flip all the pins in one port, you can always just write 255 into pin -register
01:37 PM polprog: look at the schem
01:37 PM Jartza: ldi r16, 255; out _SFR_IO_ADDR(PINB), r16
01:38 PM polprog: the ddr is written 0x01 anyway
01:38 PM polprog: going swimming now
01:38 PM polprog: cya
01:40 PM Jartza: sure, but you could also switch one pin just by using cbi
01:40 PM Jartza: too complicated asm for such a simple thing
01:40 PM Jartza: and also a bit misleading
01:40 PM Jartza: especially those values in r20 and r19
01:41 PM Jartza: yes, r20 gets from 174 to 0, but on second loop it goes from 0 to 0
01:41 PM Jartza: 0 -> 255 .... -> 0
01:42 PM Jartza: could be explained better, but I see what you're doing there :)
02:58 PM Emil: polprog: <3
03:00 PM Emil: Jartza: write your own :D
03:00 PM Emil: Jartza: Not joking
03:00 PM Emil: or make a diff of polprogs
03:24 PM polprog: Jartza: im not explaining the delay loop for a reason it would add another screen of text
03:25 PM polprog: it's a bit too long as it is
03:25 PM polprog: i used an online delay loop gen :P
03:26 PM polprog: othwerwise i'd use a single 16 bit decremented counter... or call the _delay_ms macro
03:27 PM polprog: it's sole purpose is to let someone copy that code, read about what it does and blink a led ;)
03:28 PM polprog: also wanted to demonstrate the in instruction
03:43 PM Emil: Hmm
03:43 PM Emil: I wonder if we could make avrdude autodetecting
03:44 PM JanC_ is now known as JanC
03:44 PM Emil: instead of having to specify a chip it would autodetect
03:44 PM Emil: Based on signature
03:48 PM hetii: Hi ;)
03:48 PM hetii: Emil, sure,
03:49 PM hetii: You can do this in simple way to call avrdude twice, one to get signature and second to use it for real work purpose
03:49 PM hetii: of course you can also change that in avrdude code and then call it just one itme
03:49 PM hetii: *time
03:51 PM Emil: hetii: yeah imho it should be pushed upstream
03:52 PM hetii: Probably they don`t do it cause sometimes avrdude detect signatures that are differ then target ;)
03:52 PM Emil: well
03:52 PM Emil: sure
03:52 PM Emil: and of course no options would be removed
03:53 PM Emil: just that, if no -p is provided it would attempt to autodetect
03:53 PM hetii: IMHO can work like that :)
04:00 PM Kevin`: is there a better channel for atmel arm?
04:04 PM Jartza: Emil: or add "-p auto" for autodetect
04:04 PM Jartza: then it wouldn't break existing functionality, unless implicitly specified :)
04:15 PM Kevin`: anyway, if someone has used atmel sam-ba on windows, is there a way to either set up a board config such that it uses an external oscillator by default, or to reconnect to a board without closing the application and entering all the settings again?
04:44 PM polprog: What do you think about this board for self taught FPGA development? under linux. https://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=218&No=708
04:45 PM Lambda_Aurigae: buy me two and give me six months to test and I will let you know.
04:46 PM polprog: yeah
04:49 PM Kevin`: polprog: do you have a specific project goal in mind? if not it's an fpga and should be fine.. if so, there are demo boards with built-in ram, storage, serial transceivers, etc for most purposes
04:49 PM Emil: polprog: buy
04:49 PM Emil: polprog: the
04:50 PM Emil: polprog: icestick
04:50 PM Emil: or the bigger one
04:50 PM polprog: im looking for one that has a sane development env under linux
04:50 PM polprog: Kevin`: i can attach the peripheral chips, it would be better that way :D
04:51 PM polprog: same way i learned avrs
04:51 PM Lambda_Aurigae: icestick is 25 dollars at digikey..but they don't have any.
04:52 PM polprog: hmm theres even some gui ide for icesticks, if they are making guis that means the sane tools are pretty good
04:56 PM polprog: farnell has one in a good price
04:56 PM polprog: 100 zlotys, 23 euros
04:56 PM polprog: for this price i could buy two as well
05:08 PM polprog: Lol emacs has a verilog mode. Nice
05:08 PM polprog: installed by default
05:09 PM Emil: polprog: yes
05:09 PM Emil: icestorm
05:10 PM polprog: so icestick it is
05:10 PM Emil: http://www.clifford.at/icestorm/
05:10 PM polprog: now we need to wait for money :P
05:11 PM polprog: this looks like a good verilog tutorial in the meantime: http://www.asic-world.com/verilog/verilog_one_day1.html#Block_diagram_of_arbiter
05:12 PM polprog: besides the fact that the graphic design is older than me on that site it's pretty good
05:13 PM polprog: what do you think about the graphic design of my tutorial?
05:15 PM Emil: polprog: pretty hacker ;)
05:16 PM polprog: plays well with the rest of the site?
05:19 PM polprog: now i need to get https
05:22 PM polprog: night!
05:24 PM Emil: polprog: use nginx and I can give you direct config
05:34 PM aarcane: so I whipped this up to rapidly service an ISR for the ADC... https://gist.github.com/aarcane/b8546eff128619eb8418b2d14c29697e
05:38 PM Emil: aarcane: using the register keyword is baaad
05:39 PM aarcane: Emil, it's fuuuun. I had to find a pair that were never clobbered.
05:40 PM aarcane: but it'll still work, just slower, if you take those out... but they're updated *every* time the ISR triggers, so they should be in register, because it saves about a dozen cycles due to movws, ins, and outs.
05:40 PM Emil: true
05:40 PM Emil: So how does that work
05:41 PM Emil: as an algorithm
05:41 PM aarcane: which? the ISR or the min/max?
05:41 PM Emil: minmax
05:42 PM Emil: that doesn't branch
05:42 PM aarcane: sbrs/sbrc don't branch, they just suppress all the actions of the instruction behind them in the pipe, turning into into a nop.
05:43 PM aarcane: turning it into.
05:43 PM Emil: that's branching
05:43 PM Emil: any jumping around is branching
05:43 PM aarcane: not quite.
05:44 PM aarcane: it doesn't actually jump or manipulate the program counter intrinsically
05:44 PM aarcane: the pipeline continues as usual, but the flags are set so that the following instruction is inert.
05:44 PM Emil: PC ← PC + 2, Skip a one word instruction
05:44 PM Emil: PC ← PC + 3, Skip a two word instruction
05:44 PM Emil: yes
05:44 PM aarcane: subtle but significant difference
05:44 PM Emil: it does
05:44 PM Emil: manipulate
05:44 PM Emil: the pc
05:44 PM aarcane: but it does this in 2 or 3 cycles.
05:45 PM aarcane: 1, 2, or 3 cycles
05:46 PM aarcane: so that after the instruction is set, the next 0, 1, or 2 instruction words are nullified, but continue through the pipeline as usual
05:47 PM aarcane: basically, a movw gets pushed through the pipeline whether the condition is true or not, but the write lines on the output of the CPU are what are disabled, rather than the PC being directly manipulated.
05:49 PM Emil: Interesting
05:49 PM aarcane: the result is that the whole operation (sbrs, movw) takes a fixed amount of time and doesn't result in a branch or jmp operation.
05:51 PM aarcane: I wanted to use the arithmetic shift version, but arm, afaik, doesn't have a barrel shifter implemented.
05:51 PM aarcane: avr**
05:51 PM aarcane: arm probably does have a barrel shifter, lol
06:09 PM ZeroWalker: trying to get SPI to work on my STM32, i got a clock passed into PA5 and data into PA7, nothing on PA6. But i can't ever seem to read any data at all
06:12 PM Tom_itx: phase and polarity right?
06:16 PM Tom_itx is now known as Tom_L
06:16 PM ZeroWalker: haven't touched them so they should be default, which is ": CK to 0 when idle" and "The first clock transition is the first data capture edge". New to SPI so not sure what these are for really
06:16 PM aarcane: ZeroWalker, check your cs settings
06:16 PM ZeroWalker: cs?
06:16 PM aarcane: chip select
06:16 PM ZeroWalker: ah, it's 0 by default which is slave
06:16 PM ZeroWalker: or wait, that's the other one
06:17 PM Darkmoon_UK: Anyone else here using JetBrain’s CLion as an AVR IDE ?
06:18 PM ZeroWalker: file:///F:/Desktop/en.CD00171190.pdf 25.51 which do you mean?
06:18 PM ZeroWalker: 25.5.1*
06:19 PM ZeroWalker: i use Arduino in Visual Studio with STM32, though i kinda dislike the Arduino interface, it's weird for me, but the other ones seems even weirder
06:21 PM aarcane: okay, it's probably the SS pin. Read up on it. Also, your desktop is different from my desktop, so your link is broken
06:22 PM ZeroWalker: wtf i linked wrong, thought it was the website lol (was open in chrome xd)
06:22 PM ZeroWalker: http://www.st.com/content/ccc/resource/technical/document/reference_manual/59/b9/ba/7f/11/af/43/d5/CD00171190.pdf/files/CD00171190.pdf/jcr:content/translations/en.CD00171190.pdf
06:22 PM ZeroWalker: thought the SS pin was optional or something
06:22 PM ZeroWalker: when i read on SPI the only thing that seems to be normal is MOSI,MISO and SCK
06:28 PM aarcane: Read up on page 703
06:29 PM aarcane: wait, that's master mode, hang on
06:33 PM aarcane: last point on page 702
06:35 PM aarcane: and 706 point 4. You either need tow ire up the ol' NSS, or you need to use software mode.
06:36 PM ZeroWalker: but isn't that if there are more slaves? for me it's just a master, which sends data constantly (it's actually not SPI, but as it has a clock and a data line i can treat it as such).
06:36 PM ZeroWalker: so there would be no where to wire the NSS to
06:37 PM aarcane: ZeroWalker, tack it to ground, or set SSM and SSI. The hardware won't listen unless it's told to.
06:38 PM ZeroWalker: will try
06:38 PM aarcane: the SS or CS(as it's sometimes called) pin is there to tell the chip "You. Yes you. Stand Still Laddie" while the master communicates with it. When it's done talking, the chip can (and in this case does) stop listening.
06:39 PM ZeroWalker: oh now i actually do get some data;o
06:39 PM ZeroWalker: connected the nss to gnd
06:44 PM aarcane: Darkmoon_UK, I like clion, but I use atmel studio for my avr development. There's a lot of posts online about using it though
09:32 PM enh: hi
09:35 PM Darkmoon_UK: Hi
09:44 PM Darkmoon_UK: AVR Studio is okay… obviously the tight integration is nice, but it still boggles the mind how the embedded industry seems so tied to Windows
09:45 PM Darkmoon_UK: You’d have thought for engineering & low-level stuff, they’d have favoured *nix generally.
09:45 PM enh: people in general are tied to windows
09:45 PM Darkmoon_UK: …sad but true.
09:46 PM enh: it is better to have a known shit than an unknown good
09:47 PM enh: for them, of course.
09:56 PM ColdKeyboard: Can anyone recommend a working library for controling MCP4661 digital potentiometer?
10:31 PM ZeroWalker: can you have a passthrough from SPI to USB Serial?
11:22 PM Ameisen: Darkmoon_UK - when using tools, Linux vs Windows matters little
11:22 PM Ameisen: though I build my AVR stuff via Visual C++ using some ruby scripts which handle gcc/ld/etc and autodeploy to the device