#avr Logs

Dec 01 2017

#avr Calendar

12:40 AM _ami_: we are shifting today.. so have to packing in office.
12:43 AM _ami_: have to do*
12:43 AM _ami_: need to pack PCs and other stuffs
12:43 AM _ami_: and the new location is just the other side on the same floor.
12:43 AM _ami_: but you got to pack things
12:43 AM _ami_: so fuckign annoying
04:15 AM nabil: having made this made this mistake... I want to double check
04:15 AM nabil: for atmega32u4, this fuse bits
04:15 AM nabil: -U lfuse:w:0xde:m -U hfuse:w:0x99:m -U efuse:w:0xf3:m
04:15 AM nabil: would only remove divide by 8 right?
04:33 AM nabil: having made this made this mistake... I want to double check
04:33 AM nabil: <nabil> for atmega32u4, this fuse bits
04:33 AM nabil: <nabil> -U lfuse:w:0xde:m -U hfuse:w:0x99:m -U efuse:w:0xf3:m
04:33 AM nabil: <nabil> would only remove divide by 8 right?
04:41 AM APic_ is now known as APic
06:48 AM nuxil: nabil_, only the low fuse controls the clock settings.
06:48 AM nuxil: DE is indeed without div8
06:53 AM nuxil: nabil_, if in doubt. check out the fuse calc in the topic
07:39 AM wondiws: hi, do I really need to but a memory barrier around sei() and cli()?
07:39 AM wondiws: put*
07:39 AM LeoNerd: What gives you that impressin?
07:39 AM LeoNerd: *impression
07:43 AM wondiws: LeoNerd, those two are already volatile asm
07:43 AM wondiws: so, I can expect them to run in the order I write them, right?
07:44 AM LeoNerd: You are sounding more and more confused on a variety of subjects now
07:44 AM LeoNerd: I'm finding it hard to guess what question you're /really/ asking based on it. Can we start again?
07:45 AM wondiws: LeoNerd, alright, let's break it up in several questions: memory barriers are to make sure the code runs in order, regardless of optimization, right?
07:46 AM wondiws: question #2: If I use -O0 or -Os, I don't need GCC_MEMORY_BARRIER, right?
07:47 AM LeoNerd: No, they're not
07:47 AM LeoNerd: So that's the first problem here :)
07:47 AM LeoNerd: Memory barriers are to ensure that all _side effects_ in shared memory are observed in the correct order
07:48 AM wondiws: LeoNerd, so it's necessary for multithreading?
07:49 AM LeoNerd: Handwavy-yes. Not forgetting that things like interrupts are a *kind* of multithreading
07:50 AM Ameisen: tried explaining to some of my coworkers back in the xbox360 days that you can't just read/write from variables willy nilly across threads
07:50 AM Ameisen: and 'volatile' wasn't sufficient, either
07:53 AM nuxil: changing variables across threads can be a nightmare. the well know race condtion. if one dosent do proper mutex etc.
08:00 AM nuxil: and if you never experienced the race condition. you never done much multithreading :p
08:00 AM LeoNerd: I usually like to keep only one thread of control in charge of any particular piece of memory. Though sometimes that's unavoidable even on AVR, e.g. signal handlers
08:01 AM LeoNerd: My mainloop scheduler usually keeps that fairly safe though; my task functions all run with interrupts disabled
08:01 AM nuxil: a few years ago i wrote a program in python. it was multithreaded. i had a race condidion and a priority issue in one of my thread.
08:01 AM nuxil: and tracing it was not easy :p
08:02 AM nuxil: it was a app for a game called arma2. the program was named BEC. (Battleye extended controls) :), was popular on dedicated servers.
08:15 AM nuxil: it was one of the few games i liked. but i rage quit developing the app. because bohemia basically allowed server owners to monetize their servers. and 90% of these monitized servers where running 3rd party free apps. like mine and others.
08:19 AM nuxil: and man the server owners got pissed :p because BEC has a diale home function. than the respons it was given was. exit, so each time they started the program it auto exited :p
09:38 AM polprog: Lambda is away for a longer time now :(
09:39 AM polprog: im the only one left in the dalnet channel
09:53 AM Ameisen: Is there a site anywhere that has optimal algorithms (either in C, C++, or assembly) for operations like int to string, string to int, etc?
09:54 AM Ameisen: I know the naive algorithms, but I also know that better ones exist
09:54 AM Ameisen: and when taking into account the oddities of AVR, I'm sure there's even better algos
10:02 AM _ami_: why do you need algorithms for converting string to int? is n't atoi() exist for this?
10:02 AM _ami_: sprintf() for doing tghe opposite.
10:02 AM _ami_: the*
10:29 AM Ameisen: atoi can work for me, I do not want to use *printf routines for a variety of reasons.
10:29 AM Ameisen: one being that they're incredibly inefficient for converting just one value.
10:29 AM Ameisen: itoa and such are an order of magnitude faster, generally
10:29 AM Ameisen: however, there isn't an itoa and such for every type size, especially [u]int24
10:30 AM Ameisen: and my goal is to reduce clock overhead
10:30 AM Ameisen: so working at a higher size then truncating is less than ideal
10:37 AM polprog: when i was doing programming competitions and was new enough to C[++], i wrote my own itoa (didnt know itoa existed lol). it was simply a loop that did modulo and add. that might be heavy for avrs since they (i think so) dont have HW division.
10:37 AM polprog: and i wrote atoi the same fashion
10:38 AM Emil: modulo is rape for avrs
10:38 AM polprog: but in an extreme case, if memory allows, you could write a super-fast single byte itoa with a lookup table ;) that's insane, but hey, ldi, addiw, ld
10:39 AM polprog: Emil: division is hard even for hoomans
10:39 AM polprog: compare the way to do addition/substraction/multiplication on paper with division on paper
10:39 AM polprog: (for stuff easier than 8 over 2 or such
10:42 AM polprog: woohoo my compiled linux kernel booted in 0.66 seconds on qemu
10:42 AM * polprog can into linux
10:42 AM nuxil: doing a int div's by 2/4 etc must be superfast right. just right shift by n
10:42 AM polprog: that was just an example
10:43 AM polprog: you can simplify a fraction of 8/2
10:43 AM polprog: but if i gave you 192/32 ?
10:43 AM polprog: unless you are really good you'd have to thinki a bit longer
10:44 AM _ami_: polprog: your linux kernel might be thin like a supermodel. ;)
10:44 AM _ami_: did u compile it for x86?
10:45 AM polprog: x86_64
10:45 AM polprog: https://puu.sh/yxkxq/7c8dc4aac3.png
10:45 AM polprog: running under qemu
10:46 AM polprog: with busybox
10:47 AM _ami_: nice.
10:47 AM _ami_: why do you run linux kernel in qemu?
10:47 AM polprog: i noticed that as soon i started setting up VMs on the server my beard appeared o.o
10:47 AM _ami_: is it the latest one from upstream?
10:47 AM _ami_: 4.14?
10:47 AM polprog: _ami_: because qemu can have the image and ramdisk file passed directly
10:47 AM polprog: yes it's the newest one
10:48 AM polprog: 4.14.3
10:48 AM polprog: when i set up a bootloader i might fire it up on a real machine
10:48 AM polprog: (i should compile an x86 one, most of the junk in my room that can run linux and is unused is 32-bit)
10:50 AM Emil: polprog:
10:50 AM Emil: if you have 32 bit x86
10:50 AM Emil: throw it away
10:50 AM polprog: no
10:50 AM Emil: Please
10:50 AM Emil: yes
10:50 AM polprog: no
10:50 AM Emil: :D
10:50 AM polprog: lol why would i
10:50 AM polprog: it's a great mess-around PC
10:50 AM Emil: Because it's literal trash and garbage
10:51 AM Emil: Comeon
10:51 AM Emil: You can get free x64
10:51 AM polprog: i know
10:51 AM polprog: i got rid of some old computers from the room
10:52 AM Tom_L: but they'd make good heaters this winter
10:52 AM polprog: i only keep this, http://w.roninsupport.com/img/p/1/42027-large_default.jpg , rocky 478, just because it has a cool form factor
10:52 AM polprog: i wonder if i could run this daughtercard without the enormous mainboard
10:52 AM nuxil: why did they call it x86 (383,484,585,686 etc). x64 makes sense since its well 64bit. its not like the x86 is 86bits :p
10:53 AM polprog: 8086?
10:53 AM nuxil: but why 86.
10:53 AM Tom_L: it'd be cool if it were
10:53 AM polprog: might be because those were descendants of i386
10:54 AM Tom_L: so why did i get to name it? why not a386?
10:54 AM polprog: it's a daughtercard from an industrial PC i got for $20, running win98, probably decomissioned from the LG factory in poland
10:54 AM polprog: has some LG inventory stickers and some specialized test software on the disk
10:55 AM polprog: what i would eventually like to have is this daughtercard running free without any huge mobo.... it has what i need - ethernet and some storage (CF card)
10:55 AM polprog: might have to design a PCI/ISA supply PCB for it..
10:56 AM polprog: everything else is on the board - the mainboard has some passives and connectors for power. even the case buttons were wired to that card
10:56 AM polprog: it says in the manual that it's an SBC. so it should work alone
10:57 AM polprog: i need to try some stuff with it
10:57 AM polprog: i know.... the PS_ON (green atx wire)
10:57 AM polprog: might have to do with it not turning on
10:57 AM polprog: ill try to feed 12V from the lab supply
11:02 AM polprog: rocky 478 "Single board computer" https://puu.sh/yxl5F/28ac7273e2.jpg ; raspi for scale
11:06 AM learath: polprog: ah man I remember those!
11:07 AM learath: that one ... uh
11:07 AM learath: does it really have SATA + ISA?
11:07 AM learath: .. that's a bit wtf
11:07 AM learath: no that's a lot wtf
11:07 AM polprog: learath: do you know if it needs the mobo as well
11:08 AM Casper: ... isn't that like mca?
11:08 AM polprog: the best part is that the completely-THT serial IO isa card has a datecode of 2008
11:08 AM polprog: they made ISA cards in '08
11:09 AM Casper: no that's vesa local bus
11:09 AM polprog: might be, im too young to know this stuff
11:09 AM polprog: ;)
11:10 AM Casper: https://en.wikipedia.org/wiki/VESA_Local_Bus
11:11 AM polprog: okay, so the IO card is definitely ISA
11:11 AM Casper: pentium 4, 2x ddr2, ide, floppy, parallel port, 2x serial, compact flash
11:11 AM polprog: mm
11:11 AM polprog: that's right
11:13 AM learath: polprog: I'd *assume* it does not, but it really depends, I'm not familiar with that particular model
11:13 AM learath: Casper: it's probably not vesa
11:13 AM learath: it might be the vesa connector, but it's probably repurposed for something else
11:13 AM learath: I'd assume pci, maybe pci-e
11:14 AM learath: probably power too
11:14 AM polprog: it's pci
11:14 AM learath: yeah, I don't see any power, so it's got to get power over some of those pins
11:14 AM learath: unless there's a major power-in I can't see
11:15 AM learath: some warning label about "12v"? I can't read most of it.
11:15 AM learath: might give you a hint as to how to power it
11:15 AM learath: those things are typically dropped in ISA backplanes
11:15 AM learath: then the extended connector gets used for other things.
11:16 AM learath: other things varies wildly
11:16 AM Casper: learath: I suspect it is vesa, but no data on vesa, just power... that or they use vesa for faster data communication than what isa can give
11:16 AM polprog: the label says to connect 12V power before powering up
11:17 AM learath: Casper: like I said, "other things" and "Varies wildly"
11:17 AM Casper: yup
11:17 AM Casper: but....
11:17 AM Casper: is that an hardware "vmware" ? :D j/k
11:18 AM learath: honestly, I'd assume it goes in something *ancient*, and they stopped producing probably the 386 it originally shipped with
11:18 AM learath: so the company was like "What's the cheapest chip we can shove in here?"
11:18 AM learath: probably some low end celeron or something
11:18 AM polprog: ehh, looks like it needs another set of voltages on the ISA/VESA/PCI lines as well
11:19 AM polprog: i might rebuild it with the backplane i have, it was working when i got it
11:19 AM learath: polprog: you really need the backplane it came out of
11:19 AM polprog: i have it
11:19 AM polprog: i have all the stuff
11:28 AM Tom_L: meh just solder wires to the fingers...
11:32 AM polprog: i need to take a look at the mainboard closely. my guess is that they just route power rails from the atx psu to some pins on those connectors, if so, i can order the sockets and make a faux mainboard with the 24-pin socket for power distribution.
12:05 PM robinak is now known as robink
01:08 PM polprog: hmm... friday evening and no PCBS
01:08 PM polprog: sad
01:12 PM comptroller_ is now known as comptroller
01:54 PM Ameisen: [10:38:39] <polprog> but in an extreme case, if memory allows, you could write a super-fast single byte itoa with a lookup table ;) that's insane, but hey, ldi, addiw, ld
01:54 PM Ameisen: wouldn't be _that_ big
01:54 PM learath: Ameisen: it all depends on perspective
01:54 PM Ameisen: one array of 10 bytes for every digit place.
01:55 PM learath: Ameisen: to a java dev, 1tb of memory isn't "that big"
01:55 PM learath: to a sane dev 1gb isn't "that big", to an embedded dev 1mb isn't "that big" ...
01:56 PM Ameisen: itoa for uint32 would take 100 bytes. You could trim that to 90 bytes. This is also an array that can be shared across all similar functions.
01:57 PM Ameisen: unless my brain is shorting something fierce.
01:57 PM theBear: to a sane os 10mb is enough ram to exist and probly throw around some basic gui-ness at a usable speed.... to a ms os 10gb isn't enough to boot to a gui inside of 5 minutes, letalone actually do anything useful ;-)
01:58 PM Ameisen: I'll tinker with it if I get the chance
01:58 PM Ameisen: trying to write a templated printf analog for AVR
01:59 PM Ameisen: which should prevent the implicit type-casts, and also allow pass-by-reference for large types
01:59 PM thardin: why?
01:59 PM Ameisen: also easier to run validations.
01:59 PM Ameisen: thardin - performance.
01:59 PM Ameisen: mainly
02:00 PM theBear: what about by-pass-reference and in-validations ? eh ? whats of this do you have to say ? <cheeky grin>
02:00 PM Casper: 32G ram, 3G .wim image, can't boot, not enought memory o.O
02:00 PM Ameisen: how would something get invalidated during a function call that stays in scope
02:00 PM Ameisen: if that happens, something is horribly wrong
02:02 PM thardin: doesn't the compiler do an awful lot of optimization for printf already?
02:02 PM theBear: Casper, outta almost everything on good old hirens magic boot not-cd, it seems that the hdclone thingy in the old gparted minimal livecd is by far the most effective and reliable at cloning a windows invisible boot and windows drive between two hd's, not only fast, but if not booting without intervention, minimal bootice'ing is enough to get things going again... try that with yer wim's and yer ximage-gui etc
02:03 PM theBear: which compiler, and which printf ? from memory avr-libc doesn't have any native printf, but it is often implemented in minimal (or stupid silly huge libs ala *duino <grin>) functions to attach to a whatchacallit someprefixUART serial as available on just about any avr i can think of
02:04 PM LeoNerd: The usual GNU avr-libc has a printf
02:04 PM LeoNerd: It's abstract, so you have to provide some sort of function to let it output to some hardware somehow
02:04 PM thardin: that's probably not what's being optimized here tho
02:05 PM thardin: shoving bytes down serial isn't going to be the limiting factor speedwise
02:05 PM Casper: hirens is too old
02:05 PM thardin: like, you'd do vsnprintf() and send in the background
02:05 PM thardin: so vsnprintf() is what you'd want to spend effort optimizing
02:07 PM theBear: Casper, too old for what ? if you use the gparted (vs mini xp or dos) tools you can happily deal with almost every silly new sata/ahci controller, gpt no sweat, and good old ntpasswd still seems to work fine on even win10 ime, tho of course you tend to end up flippiong the bios gpt/csm boot mode and maybe flip ahci to ide to make the ancient minixp or ntpasswd tiny-linux env see it ;-)
02:07 PM thardin: there's lots of stupid code in there which fixing would benefit everyone
02:08 PM theBear: Casper, plus, with minimal trimming, it fits perfectly in the not-1gb-as-marked usb sticks i got a big bag of for free (council bought a ton of em for promo purposes, and ya know, when the 2nd or 3rd file copied to the drive corrupts the whole thing to hell 'cos they start looping back to 0 with a missing msb at just before 512mb vs the 1gb they are formatted, well, you get rid of em quick as you can, cos that ain't good publicity)
02:11 PM Ameisen: [14:02:01] <thardin> doesn't the compiler do an awful lot of optimization for printf already?
02:11 PM Ameisen: to a point. It has to follow what the spec says about variadic functions overall.
02:11 PM Ameisen: variadics are pretty bad for performance, doubly-so in C++ since they cannot pass by reference
02:11 PM Ameisen: only by value
02:12 PM theBear: wtf is a variadics ?
02:13 PM * theBear mentions that he never got into oo, not since he first saw old borland turbo c+ way waaaaay back in the day
02:13 PM Ameisen: http://en.cppreference.com/w/cpp/utility/variadic
02:13 PM thardin: theBear: functions and templates that take variable number of arguments
02:13 PM * theBear had already formed his nice sane procedural-paradigm habits by that time, he cares not for this mystical compilery
02:13 PM theBear: thardin, wowee ! what will they think of next
02:13 PM nohitzzz: polprog nuxil https://s33.postimg.org/ex68uwzen/IMG_20171201_162818.jpg
02:13 PM nohitzzz: it came
02:14 PM Ameisen: With C++, you have (generally) better alternatives like with variadic templates
02:14 PM thardin: theBear: modern c++ is full of surprises
02:14 PM Ameisen: however, this will often cause multiple functions to be instantiated, so it can add more progmem
02:14 PM thardin: most of which lead to overly clever code
02:14 PM theBear: oooh, that looks liek a real one
02:14 PM Ameisen: though there are likely optimization settings to collapse them to branches
02:14 PM thardin: it's like nerd sniping
02:15 PM theBear: is that the uncommon super-sexy matt-chrome finish bridge and tuning pegs hw i see thru the blurs ?
02:15 PM theBear: modern compilers DO do some amazing stuff optimization wise, even for super simple and non-complex code, if you tell them to try hard enough
02:16 PM Ameisen: I've seen the compiler do amazing things with templates
02:16 PM Ameisen: including generate smaller code than equivalent C
02:16 PM Ameisen: having lots of context helps the optimizer.
02:21 PM thardin: how much work would it be to get static checks for stuff like ada has, in c++?
02:21 PM thardin: that'd be neat
02:21 PM thardin: but also scar
02:21 PM thardin: y
02:35 PM nuxil: nohitzzz, Nice.. i see you got enough plecks for a while :) which stratocaster is it ?
02:38 PM nohitzzz: its fender standart stratocaster, arctic white (made in mexico)
02:38 PM nuxil: oh a copy
02:39 PM nohitzzz: no copy
02:40 PM theBear: no copy, none of the copies get that font right on the head
02:40 PM nohitzzz: its basicly std strat but costs few hundred bucks less because its manufactured in mexico
02:40 PM theBear: head ? it been so long, i not sure wtf you call the tuning end of the neck
02:40 PM nuxil: hmm i see you got 4 pickups. but the picsi see had 3.
02:40 PM nohitzzz: https://www.thomann.de/fi/fender_std_stratocaster_hss_mnaw.htm
02:41 PM theBear: sure, i'll luthier the helll outta almost anything you can put in my hands, not to mention tune/service ANY organ or mechanical-based keyboard you can find ! but effed if i can talk about it effectively
02:42 PM theBear: nuxil, nah, 3, just the bridge one is a humbucker, basically 2 side-by-side, wired to cancel any picked up hum (real noticably if you got distortion gaining the eff outta not only your playing, but the formerly TINY noise between the notes) and kinda nice sharpish edge sound with bonus MUCH higher output level, if yer into silly distortion and metal/rock or anything like that, as i may or may not be
02:42 PM nuxil: nohitzzz, how much did you pay for it
02:43 PM nohitzzz: 585e
02:43 PM nohitzzz: + case 50e
02:44 PM nuxil: theBear, im a el guitar noob. i can barly play my acoustic guitar, i see 4 i assume 4. i know little to nothing about how the picups are wired. :p
02:45 PM nuxil: nohitzzz, thats cheap
02:45 PM nuxil: i think
02:45 PM nohitzzz: ive been playing completly with acoustic the past year. feels good to play an electric again
02:46 PM nuxil: mine is mostly wall decor :p
02:47 PM nohitzzz: anyone can learn to play guitar. it just needs countless repitition
02:47 PM theBear: nuxil, humbuckers are VERY common, have been for like, almost 100 years come to think of it... and they always look the same (well, sometimes a strip vs 6 round dots, but basically as the same as each other as every other regular single pickup is)
03:04 PM nohitzzz: it takes about 1-2 years of learning to get to a level where you can enjoy playing, but its definately worth it
03:11 PM nohitzzz: theBear yeah but std strats didnt use to have them humbuckers
03:16 PM nohitzzz: thats like modern version of that guitar, i took it because it might help to play metal music better, stratos arent really meant for metal traditionally
03:30 PM nabil_: I have a board with atmega32u4
03:30 PM nabil_: atmega32u4 comes with clkdiv8 by default
03:30 PM nabil_: when I leave like that and change it to no division
03:30 PM nabil_: in software
03:31 PM nabil_: it works
03:31 PM nabil_: correctly
03:31 PM nabil_: but when I change the fuse bits correctly
03:31 PM nabil_: and check with avrdude if the hex in flash is the same as the one I've got I get
03:31 PM nabil_: avrdude: verifying ...
03:31 PM nabil_: avrdude: verification error, first mismatch at byte 0x0000
03:31 PM nabil_: 0xff != 0x0c
03:31 PM nabil_: avrdude: verification error; content mismatch
03:32 PM nabil_: tried it with a simple blinking example
03:32 PM nabil_: and then changed back to default fuse state
03:32 PM nabil_: and it works again
03:32 PM nabil_: any ideas on what I might be missing?
03:33 PM polprog: nohitzzz: nice, that's a lot of picks ;D
03:34 PM polprog: nabil_: avr doesnt correctly receive the bytes and flashes garbage
03:34 PM nabil_: polprog : what do you mean? it's avrdude problem?
03:35 PM polprog: theBear: still using Hiren's? i think i was the only one who hasnt switched to UBCD
03:35 PM polprog: nabil_: cant remember from the top off my head
03:35 PM polprog: nabil_: try to run avrdude with -v or -vv option, to get more info
03:37 PM theBear: polprog, like i said, fits on my free MANY just under 500mb usb thingers (with some careful custom formatting they are 100% reliable when you don't try to get more data than they physically contain into and outta them) and well, it's got everything except a gpt and ALL ahci/modern-gpu driver environment on there for everything a normal non-windows user like me could ever need ...
03:37 PM polprog: theBear: i like it too. mine is burnt onto a cd
03:41 PM nohitzzz: polprog yeah those picks where 2e for 12 so i bought 24
03:41 PM polprog: nabil_: check your voltages during programming
03:41 PM nohitzzz: its good to have picks ;)
03:42 PM nohitzzz: also they are different thickness'
03:43 PM nabil_: polprog https://pastebin.com/FbwTkXf7
03:43 PM nabil_: not much detail added I think
03:43 PM polprog: avrdude: warning: cannot set sck period. please check for usbasp firmware update.
03:43 PM polprog: zonk
03:44 PM nabil_: but the same works when I change the fuse state to the default
03:44 PM polprog: odd
03:44 PM nabil_: yes
03:44 PM nabil_: the default lfuse is 0x5E
03:44 PM polprog: did you check your voltages?
03:44 PM nabil_: I changed it to DE
03:45 PM nabil_: at which point ? (I mean since it worked with lfuse=0x5E I assumed the problem isn't from there)
03:45 PM polprog: notice how all the hfuse/lfuse etc read back as 0x00?
03:45 PM nabil_: let me check
03:48 PM nabil_: polprog: hfuse=0x99 efuse=0xf3
03:48 PM nabil_: lfuse=0xde
03:48 PM polprog: hmm
03:49 PM polprog: you've got avrdude that properly operares on fuses but craps itself out on bulk read/write (programming the actual program)
03:49 PM polprog: how do you power the avr
03:49 PM nabil_: from the usbasp, could it be the reason ?
03:50 PM theBear: polprog, mmmm, these days i find cd''s are easier to lose and get scratched up more, not to mention that many even fullsize lappies no long have cd-holes in em, and well, my usb-cd drive is a bit waiting 2+ years running for me to resolder the medium size usb socket on again :)
03:50 PM nabil_: prolpog : the same process works fine (the led blinks too) when lfuse=0x5e
03:52 PM polprog: nabil_: my opinion is that when the avr is running slow it takes less power and the voltage doesnt drop. run it 8 times faster = 8 times more electrons = 8x amperage = voltage drops
03:52 PM polprog: this might be ti
03:52 PM polprog: it*
03:53 PM polprog: all the symptoms so far point to this
03:55 PM nabil_: yes, this can be the reason
03:56 PM nabil_: I'll try to power it externally
03:56 PM polprog: good
04:05 PM polprog: night
04:45 PM Emil: polprog: doing aoc?
05:23 PM edk is now known as demiurge
06:36 PM enh: Hi
06:36 PM enh: Good night
06:38 PM enh: For those interested, I created a group called "AVR, STM32 etc." on Telegram. Senior users here will have owner privileges there too
06:42 PM enh: https://t.me/joinchat/Cxs1iBKmgsvo7KzBgmbD9w
06:56 PM Emil: Hmm
06:56 PM Emil: I have been thinking about putting up a telegram chat with a gateway to here
07:00 PM theBear: telegram eh ? that's erm, morsey beeps translated to/from hand-writing either end isn't it ? traditionally i mean
07:34 PM day__ is now known as daey
08:52 PM anonnumberanon: it takes 41 cycles to service my interrupt and do port manipulation on 3 ports
08:52 PM anonnumberanon: at 16 megaherts that's about 2.5 microsends
08:52 PM anonnumberanon: microseconds
08:53 PM anonnumberanon: so microsecond is not achievable
08:53 PM anonnumberanon: as far as timer resolution, if the configuration of the port manipulation changes dynamically (this time, turn on this pin, that time, turn on this other bit)
08:59 PM Emil: anonnumberanon: not true
08:59 PM Emil: or well
09:00 PM Emil: I don't know how optimised your ISR is
09:03 PM anonnumberanon: let's assume it's an atmega32 at 16mghz, let me post code
09:04 PM anonnumberanon: https://paste.debian.net/hidden/3b19d320/
09:05 PM anonnumberanon: -Os
09:07 PM Emil: Entering the ISR is a minimum of 4 cycles (push to stack) but then you also have to jump (3 cycles) after which anything else needing to be done is done (pushing). To exit is 4 cycles also
09:08 PM Emil: Also
09:08 PM Emil: if executing a multi cycle instruction
09:08 PM Emil: that latency is taken into account
09:08 PM Emil: so 4+(1/2)+3+4
09:09 PM Emil: Okay so
09:09 PM Emil: I know where your issue comes from
09:09 PM Emil: also
09:10 PM Emil: what the heck are you doing with serv and servs?
09:10 PM Emil: Also, PORTx^=y isn't automatically transformed to PINx=y
09:11 PM anonnumberanon: yes i could use PINx=y but that would maybe remove 1 instruction or 2
09:11 PM anonnumberanon: or 3
09:11 PM theBear: maybe using them to make a servo or a server ? <grin>
09:12 PM anonnumberanon: serv is the current config you want your port to look like whenever the interrupt fires, and it changes everytime you fire the interrupt
09:12 PM Emil: anonnumberanon: ^= is in, xor, out
09:12 PM Emil: anonnumberanon: PIN is just out
09:12 PM Emil: anonnumberanon: wat?
09:12 PM Emil: well in that code you aren't modifying serv
09:13 PM anonnumberanon: in PINx=y , y is not a constant so you need to pull that value
09:13 PM Emil: anonnumberanon: what part of context don't you get?
09:13 PM Emil: you need to do that with ^= too
09:13 PM anonnumberanon: i know, i didn't realize this would be context-specific
09:14 PM anonnumberanon: well yeah but you think you can reduce something that takes 41 cycles to something under 16 cycles? (1 microsecond)
09:14 PM anonnumberanon: not by using PINx
09:14 PM Emil: yeah the issue is the volatile keyword
09:14 PM Emil: anonnumberanon: also use the PINx one
09:14 PM Emil: whenever you are using serv in that code
09:14 PM anonnumberanon: sure
09:14 PM Emil: gcc is generating a fetch to memory
09:15 PM Emil: like
09:15 PM Emil: load address and fetch from memory
09:15 PM Emil: If you want gcc to optimise access, use a temporary variable
09:16 PM Emil: also
09:16 PM anonnumberanon: a what?
09:16 PM Emil: why the heck are you using int
09:16 PM Emil: unsigned char, bro
09:16 PM anonnumberanon: okay
09:16 PM anonnumberanon: this was just to get a rough idea this is not good code
09:17 PM Emil: instead of saying serv everytime in that ISR, do unsigned char temp_serv=serv; and use temp_serv instead
09:17 PM anonnumberanon: to get a rough idea on the time it takes to enter an isr, get out of it and turn on 3 ports to values that dynamically change
09:17 PM Emil: well
09:18 PM Emil: 16 cycles is probably barely beyond
09:18 PM Emil: I should actually test it, also
09:18 PM anonnumberanon: what do you mean barely beyond
09:18 PM anonnumberanon: also the timer value
09:18 PM anonnumberanon: that can't be a variable either heh
09:19 PM Emil: barely beyond reachable
09:19 PM Emil: But around 20, should be easy
09:19 PM anonnumberanon: see the thing is also, serv is actually not dynamic
09:19 PM anonnumberanon: it's just the current value of the array servs
09:20 PM anonnumberanon: but each time the interrupt fires, the servs[] pointer needs to increment once, and serv take the value of it
09:20 PM anonnumberanon: the array is created before that while loop
09:20 PM Emil: If you are very keen on timing, then you must use assembly
09:21 PM Emil: In which case you can probably reach 16 cycles
09:21 PM anonnumberanon: yes my man I have been trying believe me
09:22 PM anonnumberanon: maybe "TCNT1 = 63974;" needs to be actually be TCNT1 = nextserv;
09:22 PM anonnumberanon: but how do you negate those horrible double cycle instructions push and pop
09:22 PM anonnumberanon: those take sooo long
09:23 PM anonnumberanon: literally about 10 or more cycles just entering and setting up in the ISR
09:24 PM anonnumberanon: and then the same if not more to get out of it!
09:25 PM anonnumberanon: been trying to think only in assembly but it's hard
09:34 PM anonnumberanon: Emil, i need some massive training in avr assembly in general do you think this series can take me there cause trial and error is not working for me right now? https://www.youtube.com/watch?v=_kChddN76S8&list=PLc2rvfiptPSRHQ0Kn1M8mPjp6ihWAOOYU
09:36 PM Emil: polprog recently wrote this: http://polprog.net/blog/asm/
09:36 PM Emil: and
09:37 PM Emil: rue_mohr wrote this wayyy back http://ruemohr.org/~ircjunk/avr/asmtut/asm_crash.html
09:38 PM Emil: anonnumberanon: atmega32 is not the same as the 8 bit avrs
09:38 PM Emil: wait
09:38 PM Emil: can't read
09:38 PM Emil: nvm :D
09:38 PM anonnumberanon: what?
09:38 PM anonnumberanon: lol it is
09:38 PM Emil: yeah I was like avr32
09:38 PM Emil: Should probably go to bed
09:38 PM anonnumberanon: nooooooo
09:39 PM Emil: yyeees
09:39 PM Emil: it's 5:38
09:39 PM anonnumberanon: actually yes polprog's stuff will help me
09:39 PM Emil: And others are here later today
09:40 PM anonnumberanon: the other one will be harder to understand for a beginner like me
09:41 PM anonnumberanon: will go through it too
11:23 PM day__ is now known as daey
11:33 PM amigojapan is now known as amigojapan_bnc
11:38 PM anonnumberanon: polprog, errata to your avr assembly guide: "brne stands for Break if Not Equal [zero] " is wrong
11:38 PM anonnumberanon: should be branch if not equal