#avr Logs

Oct 22 2020

#avr Calendar

01:47 AM chinry: I have a question...
01:56 AM chinry: Yeah, so I wrote a program to run on an ATTINY85 and it works perfectly except that Pin2 and Pin1 are strobing at 11hz. What could be the cause of this?
01:58 AM cehteh: most likely that your program is not as perfect as you want to believe
01:58 AM chinry: ahhh
01:59 AM chinry: could it be that it is hitting a reset?
01:59 AM cehteh: could be
01:59 AM cehteh: do you have the 100nF cap at VCC?
01:59 AM chinry: no
01:59 AM cehteh: add one
01:59 AM chinry: ok
02:00 AM cehteh: what does the tiny drive?
02:00 AM chinry: So far nothing I am just checking the voltage with an oscilloscope and logic analyzer
02:00 AM cehteh: ok
02:01 AM chinry: Wait accross the power rails right? I already have one.
02:01 AM cehteh: ok
02:02 AM cehteh: well likely the program crashes and the chip resets because of that (illegal instruction vector or so)
02:03 AM chinry: I will check for a reset vector. Let me get back to you on that
02:05 AM chinry: yes 100% correct
02:09 AM chinry: Does popping too much off of the stack result in a crash. Could that be my issue?
02:09 AM cehteh: if it is too much, then yes
02:10 AM cehteh: tinys dont have so much ram
02:11 AM chinry: hmmm
02:12 AM cehteh: what do you do that wastes the stack?
02:12 AM chinry: Interrupts
02:12 AM chinry: I can send a github link
02:12 AM cehteh: they dont nest, shouldnt use much stack
02:13 AM cehteh: deep calls/recursive calls do
02:13 AM cehteh: allocating big objects on the stack
02:13 AM chinry: Not even using Ram atm
02:14 AM cehteh: (well global allocation needs equally much, but its at least static)
02:14 AM vmt: it's probably best if you just share the code
02:14 AM cehteh: disable/comment out most of your code and then re-enable it step by step
02:15 AM cehteh: verify each part working
02:15 AM chinry: https://github.com/Chinry/syncopath
02:16 AM cehteh: omg asm :D
02:16 AM chinry: hehe
02:17 AM cehteh: avr's where designed to be programmed in C ... i'd only fall back to asm when C proved not to work
02:17 AM cehteh: but then i wont debug someone elses asm code
02:17 AM cehteh: in short: glhf
02:17 AM chinry: haha
02:18 AM chinry: So do you recommend c in the future?
02:18 AM cehteh: yes
02:18 AM chinry: I thought this project would be simple enough to bang out in assembly, but here I am a month later
02:18 AM cehteh: make it work, make it correct, only make it fast where needed
02:19 AM chinry: facts
02:19 AM vmt: i can debug this for you, for an almost-arbitrary amount of cash
02:19 AM chinry: haha, I'm good
02:19 AM cehteh: prepaied please ... yes :D
02:20 AM cehteh: possibly that amopunts to 1 lines C code :D
02:20 AM cehteh: 10 lines
02:21 AM vmt: not knowing what this does, can you correlate the 11 hz to actual functionality?
02:21 AM vmt: or some multiple of it, heh
02:21 AM chinry: broooooooo
02:22 AM cehteh: vmt: i guess that correlates to the boot timeout fuse setting on reset :)
02:22 AM cehteh: or watchdog?
02:23 AM chinry: idk brother
02:23 AM vmt: actually, you're probably right
02:23 AM cehteh: do you have that enabled?
02:23 AM chinry: watchdog?
02:23 AM cehteh: then not :) dont do
02:23 AM cehteh: WooF
02:23 AM chinry: I have the startup timer enabled for sure
02:23 AM vmt: well sure
02:23 AM cehteh: what is 'the startup timer' ?
02:24 AM chinry: I checked the longest startup time just to be safe
02:25 AM cehteh: watchdog is a hardware unit wich resets the device when you forget to pet it
02:34 AM Miyu is now known as hackkitten
02:34 AM vmt: yeah but pretty sure tinys ship without it enabled and i guess you would remember had you enabled it
02:34 AM cehteh: yeah
02:34 AM chinry: I probably f'ed up my fuse settings
02:34 AM cehteh: why didnt you leave them as default?
02:34 AM vmt: hahah, it would certainly be hilarious had you enabled watchdog and been debugging it for who knows how long :DDD
02:34 AM cehteh: at startup only set the clock divider to /1 for full speed and you are usually good
02:34 AM cehteh: well tiny85 has some amazing features you can run it at 16mhz from the internal 8mhz osc ...
02:34 AM cehteh: i ever wanted to give that a try
02:34 AM chinry: no f'ing way
02:34 AM chinry: I cannot thank you guys enough
02:34 AM vmt: oh no
02:34 AM cehteh: woot that was it?
02:34 AM cehteh: lulz
02:34 AM chinry: yes
02:35 AM cehteh: i guess not
02:35 AM cehteh: only asm fanboy :D
02:35 AM cehteh: for strict timing i would use hardware, and relax with C
02:35 AM chinry: I need to filter midi messages to check for start, stop, and clock messages. I am then sending clock to a gameboy sequencer.
02:36 AM cehteh: haha do that in C
02:36 AM vmt: oh. chiptunes. but yeah, you definitely could do that in c
02:36 AM chinry: Honestly just using ASM for practice
02:36 AM cehteh: you failed the practice :)
02:36 AM chinry: yooooo
02:37 AM chinry: Isn't there only one path to git gud?
02:38 AM vmt: i have never really learned asm, per se. i've kind of picked it up along the way when i debug stuff
02:38 AM vmt: and make sure the compiler isn't doing anything srsly stupid
02:38 AM vmt: i'm not sure where's the value in really going to town picking up asm is
02:39 AM vmt: -is
02:40 AM cehteh: a very few times i wasnt satisfied with the overhead gcc generated for ISR's
02:40 AM cehteh: written them in C .. dumped the asm
02:40 AM cehteh: used that as base for optimization
02:41 AM chinry: I mean it makes things take 10 times longer = 10 times the fun...
02:41 AM cehteh: nah only 1 bit in the fuses is enough for a lot of fun you now learned
02:42 AM vmt: :D
06:48 AM nohit: chinry: there's isnt a reason why not use assembly
06:49 AM nohit: "avr's where designed to be programmed in C" is probably most ridiculous argument i heard in a while
06:51 AM twnqx: there is one: C is more convenient :P
06:52 AM MrMobius: nohit, why is that? lots of registers and some 16 bit register capability is exactly what you want for C
07:01 AM vmt: avrs were *probably* designed to run the avr isa. i would argue c is in a pretty sweet spot in terms of ease vs. control, and would suggest c over asm unless there's some very specific niche that warrants optimization
07:05 AM MrMobius: vmt, it depends a lot on the isa. some are made in a way that a compiler just cant generate efficient assembly from the C code the way a human can, so designing an isa for C is a legit concern
07:15 AM nohit: so that makes it valid an argument against not using asm ?
07:17 AM nohit: its just one of those favourite arguments of yours, "i cant help you with this, use x instead"
07:19 AM MrMobius: do what you want. im just saying it seems believable that it was designed for C
07:30 AM nohit: i dont really get your point on this context. if the argument was "avr's werent meant to be programmed in C, use asm instead" then it would be valid
07:31 AM vmt: he's really arguing the opposite, i don't see how you fail to see it
07:48 AM twnqx: "they were designed to be programmed in C" is however not an argumet against ASM in the least.
08:43 AM nohit: it was used as one tho
08:45 AM nohit: that was the whole point of this conversation
09:20 AM MrMobius: ya not saying whether you should use asm or C
10:23 AM Rab: You should use asm because it's fun! With great things that C doesn't have, like rol and ror.
11:30 AM chinry: I agree Rab
05:38 PM markasoftware: the atmega328 datasheet says if an asynchronous input is used for timer2, that the oscillator frequency must be less than 1/4th the CPU speed
05:39 PM markasoftware: Is that "oscillator frequency" the actual asynhronous input, or the prescaled input?
05:39 PM markasoftware: eg, if I set /1024 prescaler, can I then use an asynchronous timer input faster than the CPU clock?
05:43 PM markasoftware: looks like the actual TOSC has to be slower, vv sad
05:52 PM LeoNerd: The overall idea with TOSC2 is that it's probably driven by a 32kHz watch crystal, so it's quite slow
07:05 PM cehteh_: the pin is sampled along the cpu clock time thus must be slower than that (by 4x)
07:06 PM cehteh_: prescaling happens later
11:42 PM rue_mohr: vmt are you the guy who wrote the electronics tutorial that used a PIC as a 200Hz oscillator instead of just using a 555?
11:44 PM rue_mohr: actually I tried that asynchronous thing recently
11:45 PM rue_mohr: I wanted to run a cpu at like 120Hz, but have an 8Mhz on the timer
11:45 PM rue_mohr: iirc "try it anyway" didn't work
11:45 PM day_ is now known as day
11:47 PM rue_mohr: :( I cant use a 8048 for a 4 digit hex display driver
11:47 PM rue_mohr: it could do a 3, but so can a much smaller 128 eprom
11:49 PM rue_mohr: GALs are the smallest eproms I can get
11:50 PM rue_mohr: hmm
11:50 PM rue_mohr: if I were gonna use an avr
11:50 PM rue_mohr: tiny26 I suppose
11:50 PM rue_mohr: it can drive too
11:50 PM rue_mohr: expensive tho
11:50 PM rue_mohr: that said, 16V8 are like $1ea
11:51 PM rue_mohr: wow
11:51 PM rue_mohr: almost the same from dk
11:53 PM MrMobius: GALs take a lot of current
11:54 PM rue_mohr: oh
11:54 PM rue_mohr: how much do you mean by "a lot"?
11:55 PM rue_mohr: like 20mA?
11:57 PM MrMobius: more than 100mA
11:57 PM rue_mohr: !
11:58 PM rue_mohr: ok, thats a lot
11:58 PM MrMobius: heres one thats more like 60 typical https://www.mouser.com/ProductDetail/Microchip-Technology-Atmel/ATF16V8B-15PU?qs=2mdvTlUeTfCsdBIzx6v3gA%3D%3D&gclid=Cj0KCQjw28T8BRDbARIsAEOMBcwHF2BA7GJKkyynqc3TcP0cJerapb1xW0pPdrZ7JYyDyscRb4HMY98aAvlaEALw_wcB
11:58 PM rue_mohr: what do you do if you need a 2kbit parallel memory?
11:59 PM MrMobius: ROM?
11:59 PM rue_mohr: yea
11:59 PM rue_mohr: dont say 2708