#avr | Logs for 2015-12-11

Back
[00:34:16] <Casper> hmmm avr have no 64 bits integers right?
[00:35:17] <Thrashbarg> might need to make your own if GCC doesn't
[00:36:39] <Thrashbarg> just a shame C doesn't give you access to the carry flag
[00:37:34] <Mr_Sheesh> Bit of asm'll do it usually
[00:37:40] <Thrashbarg> yup
[00:39:30] <Casper> I need to grab 4x 36 bits :/
[00:39:41] <Casper> hmmm...
[00:39:49] <Casper> might actually ignore some bits
[00:42:00] <Casper> it is actually 35 for the first packet... 34 for the second... if I counted right
[00:42:39] <Casper> first packet is partially decoded, so I don't really care about the first 3 bits... in fact, the first 4 I don't really care...
[00:42:47] <Casper> second packet... the last 4 bits are checksum
[00:42:59] <Casper> third and forth packet are copy of the first 2...
[00:44:42] <Casper> or I grab all... and a bit of bitmask and shifting to find which byte in the array to write to...
[04:01:14] <GeneralStupid> Hi
[04:04:50] <Fleck> noone is gonna talk to you with that nick :D
[04:10:28] <lald> I've seen worse
[04:10:48] <GeneralStupid> i have some questions about the ASF and its license...
[04:15:10] <GeneralStupid> I have a XMEGA 192 A3U and i want to connect it via USB with my PC (iam not exactly sure but as Virtual Serial would be nice at the beginning)
[04:15:50] <GeneralStupid> I tried LUFA but XMEGA is not supported and the developer himself wrote that it is not a good choice on XMEGA
[04:16:01] <GeneralStupid> So, what license is ASF on?
[04:18:40] <osteri> there is xmega code in LUFA, so where did you exactly get this information?
[04:22:28] <GeneralStupid> osteri: give me a second please, iam searching deans post
[04:25:47] <GeneralStupid> osteri: but he just said that LUFA isnt optimized for xmega - and never will be - so using ASF would be better
[04:26:12] <osteri> ok
[04:33:22] <GeneralStupid> i could not find anything online about the ASF license. I need it for a public project...
[04:38:14] <GeneralStupid> on the first boards i added two USB connectors, one directly into the xmega and one connected to an FT232 - FTDI... So i thought i could remove the ftdi in future relases
[05:59:11] <Lambda_Aurigae> Casper, uint64_t
[06:00:40] <Lambda_Aurigae> right in stdint.h
[06:00:48] <Lambda_Aurigae> http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html
[08:44:17] <rue_bed> #define NOP() asm volatile ("nop"::)
[08:44:17] <rue_bed> #define ABS(a) ((a) < 0 ? -(a) : (a))
[08:44:54] <Lambda_Aurigae> morning rue_bed
[08:45:04] <rue_bed> morning
[09:01:10] <twnqx> rue_bed: why do you keep posting these? :S
[09:01:55] <apo_> ABS(what can possibly go wrong)
[09:05:57] <Lambda_Aurigae> twnqx, he is posting code snippets du jour.
[09:10:04] <apo_> 07:13:12 < Mr_Sheesh> Bit of asm'll do it usually
[09:10:07] <apo_> that way lies madness
[09:11:04] <apo_> Started by getting annoyed that gcc doesn't optimize "if(SREG&(1<<C))", ended up rewriting the entire function as 60 lines of asm =P
[09:12:27] <rue_house> twnqx, so that people can use them
[09:13:06] <apo_> rue_house: Well, that ABS sucks
[09:13:12] <apo_> don't use it
[09:13:13] <rue_house> lets see yours
[09:14:43] <apo_> http://www.nongnu.org/c-prog-book/online/x843.html
[09:15:13] <rue_house> where is your macro for absolute value?
[09:15:37] <rue_house> all the page you posted says is that you need to know what your doing to get the right results
[09:16:02] <rue_house> and thats obvious
[09:16:54] <rue_house> #define inBounds(v, l, h) ((v) > (h)) ? (0) : ((v) < (l)) ? (0) : (1)
[09:17:05] <rue_house> this one will tell you if V is between l and h
[09:17:43] <rue_house> if (inbounds(v, low_limit, high_limit)) {
[09:23:06] <apo_> some shit like #define ABS(x) __extension__ ({ __typeof (x) tmp = x; tmp < 0 ? -tmp : tmp; })
[09:23:10] <apo_> but that only works with gcc
[09:23:28] <apo_> don't use macros that evaluate arguments more than once, write an inline function instead
[09:23:31] <rue_house> then dont do that
[09:23:49] <apo_> That's what I've been telling you
[09:23:57] <rue_house> if your not a good coder, just write in all in your code every time
[09:24:12] * apo_ rolls his eyes
[09:24:19] <apo_> enjoy your shitty macros, I'm going home
[09:24:28] <rue_house> one day you will learn the things that make your code unbulky and readable
[09:25:03] <sabor> #define BEGIN {
[09:25:06] <sabor> #define END }
[09:25:08] <sabor> :)
[09:25:14] <rue_house> nono, were writing C here!
[09:25:19] <rue_house> :)
[09:25:47] <rue_house> pacall compiles better tho
[09:25:51] <rue_house> s
[09:26:45] <rue_house> in that page he posted...
[09:26:50] <rue_house> int
[09:26:50] <rue_house> main()
[09:26:50] <rue_house> {
[09:26:55] <rue_house> that should be on one line
[09:27:06] <rue_house> its just a completel waste of space to break that out
[09:27:10] <rue_house> int main() {
[09:27:47] <rue_house> verticle compression, when used nicely, helps you keep all your functions short enough to fit on one screen
[09:28:07] <rue_house> all functions should be short enough to see the whole thing at once
[09:59:55] <Lambda_Aurigae> get a bigger monitor!
[10:02:22] <osteri> that macro behaviour is not obvious at all
[11:14:37] <Spine727> Hi, I'm planning on getting into c programming and microcontrollers using the avr cli tools, an arduino uno (atmega 328P) and one of these: http://www.amazon.de/dp/B0068M158K/ref=wl_it_dp_o_pC_S_ttl?_encoding=UTF8&colid=3KWYJVSO3TEX6&coliid=I2VU0L3BHVY8P6
[11:15:05] <Spine727> oops sorry for the megalink. Is my plan stupid, and why?
[11:15:39] <LeoNerd> Seems reasonable
[11:15:52] <LeoNerd> Though there are cheaper programmers available.. EUR20 for one feels a little excessive
[11:16:27] <Lambda_Aurigae> cheaper but not necessarily better...I wouldn't go with anything based on v-usb or usbasp for a first time programmer.
[11:17:28] <Spine727> Great! Is it OK to leave the atmega on the arduino board? It already has an ICSP header and a few cool things like a [better name for time-crystal]
[11:18:03] <Thrashbarg> it is
[11:18:34] <Spine727> Ok, thanks a bunch
[11:28:47] <apo_> Lambda_Aurigae: I've used an arduino as programmer quite often =P
[11:29:38] <Lambda_Aurigae> apo_, I've seen it done....I was referring to the v-usb based usbasp programmers...people seem to have more problems with those than any other programmer out there.
[11:29:49] <apo_> sure
[11:30:29] <apo_> Just saying, if you already have an arduino, might as well use that for programming
[11:30:49] <apo_> but he's gone, so... *shrugs*
[11:31:28] <apo_> I dunno what he was going to do, but it also sounds like he was under the impression that he'd need a separate programmer to flash his arduino when using the CLI stuff
[11:32:40] <Lambda_Aurigae> maybe he wanted to make his own bootloader?
[11:32:42] <Lambda_Aurigae> who knows.
[11:35:02] <apo_> 17:51:17 < LeoNerd> Seems reasonable
[11:35:03] <apo_> 17:51:30 < LeoNerd> Though there are cheaper programmers available.. EUR20 for one feels a little excessive
[11:35:13] <apo_> ergh
[11:35:45] <apo_> Don't play around with unfamiliar input devices while the IRC window is focused ;)
[13:42:02] <Jartza> hmm
[13:44:46] <Mr_Sheesh> apo_ - You mean, that way lies better code? :P
[13:54:54] <apo_> Not really
[14:06:35] <Jartza> heh
[14:06:48] <Jartza> context-switching multitasking blinkenlights
[14:07:10] <Jartza> running two tasks with "real" task switching
[14:07:20] <Jartza> like stack switch etc. on attiny85 :D
[14:07:36] <DKordic> Jartza: How?
[14:09:17] <Lambda_Aurigae> avr is actually designed for it.
[14:09:26] <Lambda_Aurigae> you can switch your stack to different places in ram.
[14:09:35] <Lambda_Aurigae> not sure on the tiny chips, but atmega chips can do it.
[14:18:39] <Jartza> yea
[14:18:44] <Jartza> https://gist.github.com/Jartza/3b869fa4b6a4afcc19b2
[14:18:46] <Jartza> this is how
[14:18:59] <Jartza> that example isn't in any means GOOD example :)
[14:19:35] <Jartza> it was meant as a proof-of-concept and demonstration of the method
[14:19:56] <Jartza> but yea. basically task_1() and task_2() are both running with their own stack and "simultaneously"
[14:20:12] <Jartza> or relatively simultaneously, current example switches task after 2k clock cycles
[14:20:47] <Jartza> starting the second task is a bit hacky :)
[14:21:16] <Jartza> I fill the second stack with "fake SREG" value and "ISR return address", which actually is task_2 start address
[14:21:19] <Jartza> :P
[14:21:35] <Jartza> so on first task switch the task_2 actually gets started as those values are popped from the stack
[14:22:58] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxUTJBcTI2dlhteGM/view
[14:23:02] <Jartza> this is how it looks like with two leds :)
[14:23:13] <Jartza> multitasking.
[14:24:04] <Lambda_Aurigae> they need to blink at different rates!
[14:27:34] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxcGZldW9XQnJMazA/view
[14:27:36] <Jartza> there :)
[14:27:56] <Jartza> nouu
[14:27:58] <Jartza> wrong
[14:29:56] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxNkNzS08wVXJ3Wmc/view
[14:29:57] <Jartza> that
[14:31:00] <Jartza> but IMO the fact that they blink at the same time is much better showing that the tasks run "simultaneously"
[15:56:01] <lald> So I'm trying to get the six-pin connector pictured here: http://fri-fl-shop.com/wp-content/uploads/2015/02/front-view.png
[15:56:07] <lald> wrong
[15:56:28] <lald> that is just some dudes head
[15:56:30] <lald> http://www.atmel.com/webdoc/avrdragon/avrdragon.section.zrr_osd_lc.html
[15:56:42] <lald> is there some kind of magic word I'm failing to google
[16:01:50] <Lambda_Aurigae> 2x6 idc connector
[16:01:53] <Lambda_Aurigae> err
[16:01:56] <Lambda_Aurigae> 2x3 idc
[16:02:22] <Lambda_Aurigae> http://www.ebay.com/itm/like/171881129858?ul_noapp=true&chn=ps&lpid=82
[16:03:00] <lald> thanks
[16:03:08] <Lambda_Aurigae> or IPC sometimes..
[16:03:13] <Lambda_Aurigae> Insulation displacement contact
[16:03:19] <Lambda_Aurigae> or insulation piercing contact
[16:03:27] <Lambda_Aurigae> but those are called IDC connectors.
[16:03:39] <Lambda_Aurigae> piles of them here.
[16:04:00] <lald> Works like magic
[16:04:11] <Lambda_Aurigae> like little teeth.
[16:04:24] <Lambda_Aurigae> I even have an IDC tool here.
[16:05:04] <Lambda_Aurigae> http://www.showmecables.com/product/IDC-Ribbon-Cable-Tool.aspx?utm_source=google&utm_medium=cse&utm_campaign=93-100-011&zmam=49733141&zmac=5&zmas=1&zmap=93-100-011&gclid=CKTOweDi1MkCFQEdaQodgx0AKw
[16:05:08] <Lambda_Aurigae> looks a lot like that.
[16:06:31] <Lambda_Aurigae> a small bench vise works wonders too.
[16:07:39] <lald> Thats a pretty clever design.
[18:10:42] <snooky> hi all
[18:10:54] <snooky> i dont really good speak english but i need help with my i2c
[18:11:01] <snooky> everyone can helped me?
[18:15:01] <Tom_itx> master or slave
[18:15:14] <snooky> i have 1 master and 3 slaves
[18:15:32] <Tom_itx> http://tom-itx.no-ip.biz:81/~webpage/avr/i2c/
[18:15:35] <Tom_itx> slave code
[18:15:44] <snooky> master atmega128, slave1 atmega8, slave2 atmega32, slave3 is an eDIPTFT70-ATP
[18:15:50] <snooky> the i2c runs perfectly
[18:16:04] <snooky> but when i connect the display to the i2c interface the i2c dont runs
[18:16:42] <snooky> the atmega128 + atmega32 + atmega8 runs fine
[18:16:59] <snooky> i connect the display. i dont can read wirte to any slave
[19:09:05] <Lambda_Aurigae> you have pin 12 grounded?
[19:09:15] <Lambda_Aurigae> and an address selected?
[19:10:12] <Lambda_Aurigae> and proper pullup resistors on the lines?
[20:15:25] <rue_house> #define SIGN(x) (x)==0?0:(x)>0?1:-1
[20:19:08] <Casper> echo UAC.ShellExecute "cmd.exe", "/c %~s0, "", "runas", 1 >> "%temp%\getadmin.vbs"
[20:19:13] <Casper> wait...
[20:19:17] <Casper> that's a batch file...
[20:19:22] <Casper> :D
[20:19:37] <Casper> ... that was the bugged version...
[20:19:59] <Casper> echo UAC.ShellExecute "cmd.exe", "/c """"%~0""""", "", "runas", 1 >> "%temp%\getadmin.vbs" <=== fixed version... and yes, quadruple quote...
[20:42:04] <rue_house> void Delay(unsigned int delay) {
[20:42:04] <rue_house> unsigned int x;
[20:42:04] <rue_house> for (x = delay; x != 0; x--) {
[20:42:04] <rue_house> asm volatile ("nop"::);
[20:42:04] <rue_house> }
[20:42:05] <rue_house> }
[20:59:01] <lald> rue_house: The (iirc) avr-gcc builtin __builtin_avr_delay_cycles was pointed out to me yesterday, will wait a precise number of cycles
[21:05:05] <rue_house> dont tell me its an optimized delay :)
[21:05:48] <rue_house> usually the number of cycles I want to delay isn't as important as the human I'm trying to satisfy
[21:06:19] <lald> Mmhmm
[21:06:42] <rue_house> but thats cool to know, thanks
[21:07:08] <lald> will the compiler really try to pull out your nop if you don't tell it its volatile?
[21:07:14] <lald> seems rude.
[21:08:14] <rue_house> I tend to use -o2 and -o3, and so it will
[21:08:23] <rue_house> its a smart compiler
[21:08:54] <rue_house> #define SetBit(BIT, PORT) (PORT |= (1<<BIT))
[21:09:03] <rue_house> ^^ it will reduce that to the right assembler instruction
[21:15:17] <lald> That is pretty cool.
[21:16:39] <lald> Have you ever read The Story of Mel? Had a neat part about "pessimizing" instructions to introduce delays
[21:16:54] <lald> I'd love to get my hands on the machine in that story, sounds like it'd be really fun to write asm for
[21:17:43] <lald> http://catb.org/jargon/html/story-of-mel.html
[21:18:14] <lald> (though of course, mel was too cool to write asm)
[21:20:33] <rue_house> if you want to save space with delays, you make far jump instructions to the next address
[21:22:13] <lald> That is basically the inverse of what Mel did.
[21:22:22] <lald> He made a long dump to the previous address.
[21:22:35] <lald> on a machine with its memory on a rotating drum.
[21:22:40] <lald> that could only rotate one direction.
[21:23:14] <lald> actually I'm not sure if it was long or relative
[21:23:42] <lald> so, he made the instruction as "pessimized" as possible to optimize his delay
[21:24:26] <lald> (why he calls it "pessimizng" makes more sense with the peculiarities of the ISA, but I'll let the jargon file give you the details if you care for them.)
[21:26:03] <lald> and the asm I saw emmitted from that builtin didn't use long jumps, it did use one short jump to the next instruction to burn an extra cycle though.
[21:34:52] <rue_house> iirc long jumps take a cycle longer
[21:34:56] <rue_house> I could be wrong
[21:35:05] <rue_house> I'v worked with lots of instruction sets in my day
[21:36:23] <lald> seems eminently likely since it has to latch in the memory address
[21:36:31] <Casper> I beleive so... 2 cycles for "short" and 3 for "long"
[21:36:44] <lald> yem
[21:36:52] <lald> yep, just like Casper said