#avr | Logs for 2016-05-02

Back
[02:33:09] <rue_house> well
[02:33:14] <rue_house> the step control code is done
[02:33:19] <rue_house> kinda
[02:33:32] <rue_house> I can definitly say it'd be faster in asm
[02:33:39] <rue_house> the question is, is it fast enough
[02:34:13] <rue_house> I wont know for a while I have to build a current regulated motor driver
[02:34:54] <rue_house> without a hardware uart, I cant push the data to the 74595 faster
[02:36:49] <rue_house> the assembler to do a table lookup is ugly, but the alternate switch/elseif is worse
[02:43:20] <rue_house> switch (status) {
[02:43:20] <rue_house> case 0: status += 7;
[02:43:21] <rue_house> case 1: status -= 10;
[02:43:21] <rue_house> case 2: status += 9;
[02:43:21] <rue_house> case 3: status += 3;
[02:43:21] <rue_house> }
[02:43:37] <rue_house> case 0: status += 7;
[02:43:37] <rue_house> d0: 87 e0 ldi r24, 0x07 ; 7
[02:43:37] <rue_house> d2: 80 93 68 00 sts 0x0068, r24
[02:43:37] <rue_house> case 1: status -= 10;
[02:43:37] <rue_house> d6: 80 91 68 00 lds r24, 0x0068
[02:43:38] <rue_house> da: 8a 50 subi r24, 0x0A ; 10
[02:43:40] <rue_house> dc: 80 93 68 00 sts 0x0068, r24
[02:43:51] <rue_house> WTF, why is it saving and reloading it?!
[02:44:22] <rue_house> it should just keep it in r24 till its done
[02:45:15] <Casper> switch code seems to be quite unoptimised on avr
[02:45:31] <Casper> and may take more space than a few if
[02:47:29] <rue_house> aha, if I make a register unsigned char temp; and do all the work with that, it works
[02:47:37] <rue_house> case 0: temp += 7;
[02:47:37] <rue_house> d6: 89 5f subi r24, 0xF9 ; 249
[02:47:37] <rue_house> case 1: temp -= 10;
[02:47:37] <rue_house> d8: 8a 50 subi r24, 0x0A ; 10
[02:47:37] <rue_house> case 2: temp += 9;
[02:47:38] <rue_house> da: 87 5f subi r24, 0xF7 ; 247
[02:47:40] <rue_house> case 3: temp += 3;
[03:00:28] <rue_house> hmm, leaves me with a long interrupt
[03:05:50] <rue_house> hmm
[03:06:11] <rue_house> if I preprogram all the serial as byte sequ3nces to the port, I can push it out in 9 cycles
[03:07:10] <rue_house> oh damn, its 1am
[03:14:55] <rue_house> ah, you cant output a literal, so its got to load all the numbers to push them out
[03:15:08] <rue_house> 13 cycles
[03:16:10] <rue_house> .. which is less than half what it takes to logically do it bit by bit
[03:18:57] <rue_house> gcc can be amazingly intelligent
[03:19:20] <rue_house> thats the second time I'v tried to trick it into doing the same thing a differnt way and its seen right thru me
[04:32:21] <jacekowski> rue_house: you forgot something i think
[04:32:38] <jacekowski> rue_house: you have nothing to jump to the end of your switch
[04:32:51] <jacekowski> rue_house: you need break;
[04:33:08] <jacekowski> rue_house: unless it's meant to go through all steps instantly
[06:33:14] <inflex> That's always a fun bung
[06:33:15] <inflex> bug
[07:41:59] <lorenzo> https://github.com/lcafaro/avr-drivers/
[07:42:06] <lorenzo> moved all the repos in a single one :-)
[08:11:47] <WormFood> I was playing around with the linker file some more, trying to make it give me a smaller interrupt vector table, and it appears I've been able to entirely remove the interrupt vector table (I gained 38 bytes, and I should have gained about 32)
[08:17:23] <WormFood> Fuck yeah! Finally something went right for a god damn change (today has been full of failure for me). Compiled and install avr-gcc 6.1 and avr-libc 2.0 from source and saved 20 bytes in my base code. I should be able to reduce the vector table, and gain about 50 bytes total, which will be used.
[08:18:49] <LeoNerd> I'd use a bigger chip instead of fighting with the compiler to give me a few extra bytes out of the interrupt vector table
[08:21:05] <WormFood> Thanks for your input there LeoNerd :P
[08:21:11] <WormFood> I don't need a bigger chip
[08:21:26] <WormFood> it's already way bigger than I need. I just would like to have a little more space for the bootloader.
[08:21:42] <WormFood> It's not that it's too small, it's that they won't let me configure it the way I want to. ;)
[08:22:08] <daey> i imagine his boss coming in, after the last byte was written. oh hey WormFood we also need you to integrate X into the chip.
[08:22:19] <WormFood> I'm the boss
[08:22:28] <daey> you have clients? :p
[08:22:47] <WormFood> you mean customers?
[08:22:52] <daey> what do you mean, it doesnt support unicode?
[08:22:58] <daey> what am i paying you for!
[08:23:48] <WormFood> it does support unicode
[08:23:56] <WormFood> It's a bootloader that I'm working on.
[08:24:02] <WormFood> At least, right this instant.
[08:24:09] <daey> i see
[08:24:12] <WormFood> the code I'll be loading, is smaller than the bootloader itself.
[08:24:51] <WormFood> I have lots and lots and lots of space for my code. It's the bootloader that's cramped for space.
[08:25:05] <WormFood> cost matters here.
[08:27:18] <daey> i need a new project :/
[08:27:44] <daey> problem is what ever you can think of, somebody is already selling cheaper and better than what you can do yourself :(
[08:29:46] <WormFood> I'm lucky in that area, because my project is a totally new product, that nobody is producing or selling right now. And I think I'll have a lot of customers for it.
[08:34:33] <Valen> I'd focus on getting the product done then screw down the cost ;->
[08:36:43] <WormFood> That's what I'm working on.
[08:37:39] <WormFood> also, gcc 6.1 is a lot more colorful. The warning messages are now colored, to help quickly identify the offending parts of your code, which is kinda cool
[08:38:50] <daey> 6.1? 0.0
[08:38:54] <daey> im on 4.9
[09:02:45] <rue_2bed> welcome to an age where the best way to avoid giving support is to come out with versions so fast nobody can keep up
[09:05:09] <inflex> true dat
[09:17:11] <jcahier> WormFood, saw that... maybe years ago. Isn't your distro that added a cool color post-parser on gcc output ? Or some option that is now aliased ?
[09:20:42] <jcahier> yeah, GCC_COLORS env var comed with gcc 4.9 and allow user to set colors. I guess it is not what I saw, but rather some separate post-parser/highlighter.
[09:23:26] <jcahier> daey, gcc 6.1 was released... April 27, 2016 :)
[09:29:39] * inflex only has 5.6 or something
[09:45:58] <rue_house> oo down to 11 cycles to bitbang shift out 4 bits with a strobe
[09:59:50] <daey> WormFood: i hope your product doesnt end up being china'd ala saleae's logic analyzer
[10:04:21] <lorenzo> saleaeaeaeaeaeae
[10:06:07] <WormFood> It was just luck that they just released 6.1. I wasn't upgrading just because it was recently released. I was just upgrading, and that happened to be the latest.
[10:06:45] <WormFood> And, avr-libc 2.0 was also relatively recently released also. That probably coincides with the avr-gcc release
[10:07:47] <WormFood> And, I think I finally figured out how to reduce the size of my interrupt table. I have to modify the linker script, and add a file, with 1/2 dozen lines in it.
[10:10:25] <WormFood> jcahier, I don't remember ever seeing gcc giving colored error/warning messages before. Maybe it isn't enabled by default, or they don't support it.
[10:25:43] <jcahier> WormFood, It was maybe one (kind-)of those script : http://schlueters.de/colorgcc.html. This one or another that do the same job
[10:26:18] <jcahier> It was before 2014 (and gcc 4.9) anyway, IIRC
[10:37:51] <daey> lol after i dissected on of our products...TPS5410's everywhere. our products are plastered with them
[10:38:00] <daey> one*
[10:38:58] <daey> thats an quite expensive 1A step down converter...
[13:42:35] <cehteh> r = (v + mask) ^ mask;
[13:42:35] <cehteh> Patented variation:
[13:42:35] <cehteh> r = (v ^ mask) - mask;
[13:42:45] <cehteh> ... yow .. wtf ..
[13:53:32] <megal0maniac> whatnow?
[13:55:55] <Casper> didn't that they said that algo can't be patented?
[13:58:31] <cehteh> algo? if it would be an algorithm at least
[13:59:10] <cehteh> well the patent seems to be invalid .. but just that someone tried it is mad
[14:35:23] <dsal> We've secretly replaced all your arithmetic classes with patent law lectures. Let's see if anyone notices.
[14:35:45] <eszett> lol
[14:36:05] <theBear> not my precious matheriticals !
[15:31:21] <antto> cehteh what is the purpose of that?
[15:31:42] <antto> must be something very useful
[15:45:54] <liwakura> i noticed what a good sheduler the interrupt logic would make
[15:46:24] <liwakura> if someone were to put everything into interrupts..
[16:05:34] <cehteh> liwakura: huh how, what?
[16:05:51] <liwakura> like, putting everything for interrupts
[16:05:57] <cehteh> abusing interrupts as threads?
[16:06:06] <liwakura> and use the interrupt delay function to shedule them
[16:06:27] <cehteh> not really nice
[16:06:28] <liwakura> the interrupt order also gives a nice priority thingiw
[16:06:31] <liwakura> *thingiw
[16:06:34] <cehteh> yes
[16:06:40] <cehteh> but there are a lot downsides
[16:07:23] <liwakura> its just like the functional approach
[16:07:31] <liwakura> its at most unusual
[16:07:39] <cehteh> interrupts have side effects (clearing some hardware bits), they start with interrupts disabled, and when you enabled them, having nested interrupts you dont have much control over stack growth
[16:08:04] <cehteh> and they have some overhead in stack and cycles
[16:09:17] <cehteh> antto: http://graphics.stanford.edu/~seander/bithacks.html#IntegerAbs
[16:17:38] <cehteh> wtf .. i found a bug in tcc
[16:24:01] <liwakura> cehteh: nono, no nested interrupts
[16:24:14] <liwakura> just cut every task in tiny pieces
[16:26:14] <cehteh> liwakura: thats what mµOS does
[16:26:39] <cehteh> but interrupts are reserved for drivers .. scheduling is done in the normal mainloop
[16:26:41] <liwakura> but just with less interrupts
[16:26:57] <liwakura> more like, yeah, mainloopy
[16:27:11] <cehteh> the mainloop is woken by interrupts
[16:50:13] <Emil> Anybody know how to get 0,25M, 0,5M, 1M and/or 2M serial speeds working in linux?
[16:52:44] <cehteh> your hardware can do that?
[16:52:51] <cehteh> stty ?
[16:57:11] <WormFood> Emil, minicom does all of those speeds, except 0.25M. I suggest you check out their source code, and see how they're doing it.
[16:57:24] <Emil> WormFood: thanks
[16:57:28] <Emil> cehteh: yes
[16:58:48] <cehteh> i have no ideas how to query the hardware about available baudrates, but i tried the other end, ultra slow and odd baudrats some time ago which worked
[16:59:06] <cehteh> 25 30 50 baud and so on
[16:59:45] <cehteh> w/ screen and arduino nano on ch540 usb/serial
[17:01:32] <antto> an error should be returned if you try to set unsupported rate or flags
[17:01:50] <cehteh> "should" :)
[17:01:57] <antto> eggzactly
[17:03:58] <cehteh> screen doesnt return errors
[17:04:30] <cehteh> stty does :)
[18:48:40] <twnqx> Emil: i can also pastebin you some C code for that
[18:49:20] <twnqx> or well, can tomorrow when at my desktop...
[18:52:03] <twnqx> or just https://github.com/chrschmidt/spitool/blob/master/serial.c lines 55 to 70 + https://github.com/chrschmidt/spitool/blob/master/buspirate.c lines 36 to 48 for constants
[19:16:04] <cehteh> so .. hacked a small lib for rational numbers, not yet on avr, lets see if it becomes useful
[19:17:42] <Casper> that dosen'T sound too good :D
[19:18:39] <cehteh> heh
[19:18:45] <cehteh> just fun
[19:20:50] <cehteh> http://public.pipapo.org/rationals.c
[19:23:03] <cehteh> https://en.wikipedia.org/wiki/Buffon%27s_needle .. interesting method to determine pi :D
[21:55:23] <inflex> wonder how much power it'd take to keep a very small volume cool to about 15'C, in the order of maybe a 10x10x10cm volume
[21:55:56] <inflex> Mostly to keep my solder paste viable
[21:59:50] <dsal> The paste I use claims to survive at room temperature for a long time. I've had this tube on my desk for a while.
[21:59:59] <dsal> Friend recommended it. It's not cheap, but good stuff.
[22:02:54] <inflex> http://au.element14.com/aim-products/ct-l63-s0515/solder-paste-63-37-183-c-15g/dp/2366335/false <=- one I'm using now
[22:03:01] <inflex> which is a few steps up from the 4711 from DX
[22:03:27] <inflex> I like that it starts melting at 183
[22:05:39] <dsal> I got this stuff: http://www.zeph.com/zephpaste.htm
[22:07:11] <inflex> crikey, double the price
[22:07:28] <inflex> well, for now, my stuff is doing well with this new paste... for now
[22:12:11] <dsal> Yeah, not cheap stuff. It's good for doing boards by hand, though. Right amount of sticky to the pads, etc...
[22:13:04] <DKordic> inflex: AFAIK wells, subways and similar are at about 9'C at all times. So just dig a deeper hole ;) .
[22:13:24] <cehteh> fridge is too cold?
[22:14:28] <cehteh> for small volume only a few degrees below ambient a peltier might be ok (they are horribly inefficient, but when you isolate that small box well it may work out)
[22:17:51] <inflex> ja, was thinking a peltier might be my only option, with perhaps 50mm thick insulation
[23:01:34] <_ami_> if i use avrdude instead to upload hex file to arduino, will it override the bootloader installed? i think it will not. since bootloader will modify the flash and install the next program? Am i correct? programmer settings in avrdude will be arduino. avrdude -c arduino ...
[23:02:58] <LoRez> _ami_: normal .hex files are built to install at the bottom of the flash space. bootloaders are built to be at the top end
[23:03:56] <_ami_> LoRez: cool, thanks.
[23:04:37] <_ami_> I hope to write bootloader one day for avr chip just to understand it completely :)
[23:07:44] <_ami_> LoRez: btw, if you hate Arduino IDE gibberish, use this: https://github.com/amitesh-singh/amiduino/tree/master/avr/ami-arduino-cmake
[23:08:03] <_ami_> i think its more organized and gives more control to developer.
[23:47:13] <Casper> _ami_: avrdude will or will not overwrite the bootloader, depending on the way you flash it. If you use the bootloader then no. If you use an external programmer then yes
[23:47:29] <Casper> and why use something else than make? no reason to
[23:53:23] <inflex> lo there Casper
[23:54:12] <Casper> hi ya inflex