#avr Logs

Aug 17 2019

#avr Calendar

11:15 AM retrosenator: since atmega328p can't do 16mhz at 3.3v...
11:19 AM retrosenator: is is safe to set div8 fuse and use 16mhz xtal?
11:19 AM retrosenator: booting to 2mhz, then I will switch to 4mhz in software
11:39 AM LeoNerd: retrosenator: Should be fine yes, that's sortof the point of that fuse
12:21 PM Helle: So uuuuh, I am trying to make sense of an AppNote, using the input capture unit, does the counter get implicit reset when an input capture happens or not ?
12:22 PM Helle: or is the PWM capture sample code simply relying on wraparound arithmatic and hoping no compiler messes with that
12:23 PM LeoNerd: Which chip? What appnote?
12:25 PM Helle: and yeah, I just read it and it looks like they are just doing that
12:25 PM Helle: well, I read it with a bit more care involved :p
12:26 PM Helle: AVR135 and it applies to various
12:58 PM Helle: a quick double check, I can on the ATTiny84 use the Timer1 for both input capture and output compare at once, right ?
01:02 PM cehteh: new to me that input capture resets the counter, but mkay maybe some chips do that or can be configured to
01:03 PM cehteh: and input capture on the avrs i know is independent from output compare
01:03 PM Helle: cehteh: misunderstanding, it doesn't, they are using wrap-around arithmatic in the example and not mentioning it, which is a bit of a head scratcher when you are used to more uuuh, defensive code
01:05 PM cehteh: Helle: general rule of thumb is to never touch (reset/stop/change) a running timer when you want reliable tiing
01:05 PM cehteh: needs bit care and math to get it right but at least the timing wont be impressed by the lack of your math skills and just goes on
01:06 PM Helle: cehteh: good to know, I wasn't planning on it, I just was wondering about it as I am combining input capture and output compare, so the numbers become relevant there
01:06 PM cehteh: aka, when querying the timer its a bit tricky to handle overflows and incooperate the overflow bit
01:07 PM Helle: I mean my PWM measuring is 1kHz on a 8Mhz ATTiny, I think I'll be okay with the 16 bit counters :P
01:08 PM cehteh: dunno what you are doing, but when the signal is correct then there is a chance that the code is not totally broken
01:08 PM Helle: hehe
01:08 PM Helle: More annoying is that I may need a scope, though my multi-meter has a reasonable duty-cycle output and all
01:08 PM cehteh: while often correct signal can coexist with somewhat broken code, doing odd things in corner cases or just happen to do the right thing by chance :)
01:08 PM LeoNerd: Overflow is sufficiently rare that you can increment your own counter-extension int in an interrupt handler
01:09 PM LeoNerd: E.g. turn a 16bit timer into a 16+16=32bit with software
01:09 PM cehteh: yes, but then when you want to query the timer + this extension you need to be careful that you dont get it on the wrong foot
01:09 PM Helle: LeoNerd: yeah, but in this case the input captures happen multiple times per counter loop through, which means it's fine
01:10 PM cehteh: thats a ultra rare corner case (once every 65536 ticks) but may have ugly results
01:11 PM cehteh: Helle: scope is nice for timing .. but these cheapsaleae logic analyzers ($12) are realyl worth it when you want to extend your toolset cheaply
01:11 PM Helle: cehteh: oh, yeah, forgot that I am just doing digital for once, heh
01:12 PM Helle: which ones are $12 though ?
01:12 PM cehteh: do you need to query the 'global' time .. that is overflow counter + TCNT ? .... the you need to be careful about the corner case i just saied
01:13 PM cehteh: https://www.amazon.de/AZDelivery-⭐⭐⭐⭐⭐-Logic-Analyzer-gratis/dp/B01MUFRHQ2/
01:13 PM cehteh: 9.99 even cheaper
01:13 PM Helle: cehteh: oh, no, I have no values above 65536 that would be valid anyway, if that happens I am pulling the brake
01:13 PM cehteh: yeah but i suppose/suggest you dont stop the timer so overflows happen
01:14 PM Helle: cehteh: yeah, but the math also overflows and those two overflows cancel eachother out
01:14 PM cehteh: your counting period may start at 65530 and stop at 103 :)
01:14 PM cehteh: well depends
01:14 PM Helle: the way I have it arranged now (and the way the example does it) it cancels out :P
01:14 PM cehteh: but ok when it works in your case then fine
01:15 PM cehteh: yes ok
01:15 PM Smidge204: +1 recommend a logic analyzer.
01:15 PM cehteh: working nice under linux with sigrok/pulseview
01:16 PM Smidge204: But be wary of using it for timing adjustments since the timing it shows will be limited to its sample rate
01:16 PM Helle: cehteh: ie, u16_t mathed 103-65530 is the correct number :P
01:16 PM cehteh: and higher rates are a bit flaky on the usb side
01:16 PM Helle: cehteh: yeah, it's not super tight on this
01:16 PM cehteh: Helle: yes that works
01:17 PM Helle: Dieser Artikel kann nicht in die Niederlande geliefert werden. damn you Germans
01:17 PM cehteh: eventually you may want a scope but logic analytzer and scope complement each other, they dont substitute each other
01:17 PM cehteh: lol
01:17 PM Smidge204: Pulseview is also vry nice, except it does not handle unplugging/replugging a connected device gracefully (it crashes out)
01:18 PM LeoNerd: PulseView is nice
01:18 PM cehteh: should be available elsewhere ebay or amazon in netherlands .. there are plenty clones out there
01:18 PM Smidge204: Trying to view serial traffic on a scope is a nightmare
01:18 PM Smidge204: Pulesview lets you save the sampled data to file and look at it later :D
01:18 PM cehteh: even decodes it for you
01:19 PM Smidge204: Yeah stack decoder
01:19 PM cehteh: but for timing analysis a scope is nicer
01:19 PM Smidge204: Absolutely, but it can be done on an LA if the sample rate is fast enough
01:20 PM LeoNerd: I generally can't get more than 8MHz out of mine
01:21 PM LeoNerd: Whereas my DS1054Z will easily do 100Ms/sec
01:22 PM Smidge204: I have a LWLA1034 that will do 125MHz sampling rates, which is at least an order of magnitude more than I can ever imagine needing
01:22 PM Smidge204: (Also the I2C decoder in the DS1054Z is pretty shit)
01:24 PM LeoNerd: I²C decoder in a scope will give you numbers, on a good day
01:24 PM LeoNerd: PulseView will tell you names of the registers of the chip you are talking to
01:26 PM Smidge204: Really? Wasn't aware of that
01:28 PM Smidge204: One feature I'd like is the ability to trim the samples... cut out (or at least hide/collapse) portions of the waveform so distant parts can be visually brought closer
01:28 PM LeoNerd: Yes definitely
01:28 PM LeoNerd: Would be lovely
01:39 PM Smidge204: Looks like Pulseview 0.4.0 files are not compatible with 0.4.1 files :/
01:39 PM Smidge204: Wait no I did a dumb
01:46 PM Smidge204: Aw yeah 0.4.1 lets you add markers. That's fantastic
05:41 PM Smidge204: Super annoying that ANDI only works with registers R16 and up :(
05:48 PM cehteh: esp there are AVR's with only 16 registers :)
05:50 PM Smidge204: I can only assume those either do not have that instruction or the restriction does not apply in that case :p
05:50 PM cehteh: i guess they dont have that instr .. these are the smallest most cripled avr's
05:58 PM cehteh: ah
05:58 PM cehteh: A typical implementation of the AVR register file includes 32 general purpose registers butATtiny4/5/9/10 implement only 16 registers. For reasons of compatibility the registers are numberedR16...R31, not R0...R15
05:58 PM cehteh: lol
05:59 PM Smidge204: Nice
05:59 PM Smidge204: So assuming instrucitons like ANDI are supported, it's just impemented (probably are) on the registers that exist
06:00 PM Smidge204: Surely the reason is one of practicality... the circuitry needed to support some instructions on all registers must be too unwieldy
06:00 PM cehteh: no idea, i never used anything smaller than tiny13
06:01 PM cehteh: and usually dont do asm
06:03 PM Smidge204: I can't think of any other reason why. The number of connections must grow exponentially
06:07 PM Smidge204: Currently writing up a routine that takes a time (hh:mm) as two binary coded decimal bytes and generates a string of file IDs for audio playback :D
06:09 PM Smidge204: Only 26 instructions so far and it should handle hours, and minutes other than "-teen" and "00" values. Not too shabby
11:57 PM day__ is now known as day