#avr | Logs for 2016-01-05

Back
[05:02:09] <nuxil> morning
[05:03:26] <nuxil> can anyone explain the macro "REGISTER_BIT" for me. im having a hard time understanding it
[05:03:28] <nuxil> http://pastebin.com/9wgJqaWG
[05:05:02] <Xark> nuxil: The ## is C pre-processer "token pasting" operator. So, if you pass in 2, it will paste it and get "bit2" from the bitfield.
[05:05:24] <nuxil> yeah i know the ##
[05:05:40] <nuxil> but what about volatile _io_reg*)&rg)->bit
[05:05:55] <nuxil> its a pointer to a referance ?
[05:06:00] <Xark> nuxil: It is just a fancy way of setting a single bit in a register.
[05:06:25] <nuxil> yea. but can you explain it to me, how does it work :)
[05:07:08] <Xark> It is casting a pointer to volatile _io_reg to the address of whatever register you pass in as "rg". Then it will set bit "bt" of that register.
[05:07:45] <nuxil> ic i think
[05:09:19] <Xark> In the end a fancy way to set an individual bit in a memory location (presumed to be a register).
[05:11:06] <Fleck> reg |= (1<<bit);
[05:16:47] <nuxil> Fleck, ?
[05:17:21] <nuxil> that just adds 1 in right. while the macro does both 0 and 1 if i got it right.
[05:19:51] <Xark> Yeah, more like reg = (reg & ~1<<bt) | (newbit<<bt);
[05:20:48] <nuxil> :)
[05:23:22] <Fleck> reg &= ~(1<<bit); :D
[05:32:04] <nuxil> Fleck, hehe. but what if you dont know what the bit is. 0, or 1 you want to add to the register ;)
[05:33:26] <Xark> Yeah, so if (newbit) <previous Fleck post> else <latest Fleck post> :)
[05:33:26] <Fleck> as Xark posted combine those two
[05:33:38] <Xark> ^
[05:33:50] <Jartza> oh
[05:34:06] <Jartza> I have bit more advanced version of that macro :)
[05:34:38] <Jartza> http://pastie.org/10670363
[05:34:45] <Jartza> there's also more magic macros in that :)
[05:34:52] <Jartza> we just discussed that on the other channel today
[05:35:00] <Jartza> that "BITP" macro is basically the same
[05:35:08] <Jartza> BUT you can use the bit name
[05:35:10] <Jartza> like:
[05:35:11] <nuxil> other channel ?
[05:35:22] <Jartza> #define LED_OUT BITP(PORTB, PB4)
[05:35:32] <Jartza> so you don't have to know what bit number PB4 is
[05:35:42] <Jartza> then in code you can just say LED_OUT = 1;
[05:35:46] <Jartza> or LED_OUT = 0;
[05:35:50] <Jartza> nuxil: #hackvana
[05:36:22] <nuxil> nice macros
[05:36:33] <Jartza> that makes LED_OUT a "variable" which just sets or clears PB4 without touching the other bits
[05:36:44] <Jartza> nuxil: the last 3 are the ones you want to use maybe
[05:36:52] <Jartza> like BITS_SET(DDRB, PB3, PB5, PB7)
[05:37:09] <Jartza> that would turn into DDRB |= (1 << PB3) | (1 << PB5) | (1 << PB7)
[05:37:17] <Jartza> but it's much easier to write
[05:37:25] <nuxil> yea
[05:37:32] <Jartza> both BITS_SET and BITS_CLEAR accept 1-8 bits to set or clear
[05:37:35] <nuxil> thanks
[05:37:57] <Jartza> and BITS_SET_EX(DDRB, PB5) would set all the other bits to 0, except PB5 to 1
[05:38:20] <Jartza> while BITS_SET and BITS_CLEAR will only change the bits you define (and leave the rest of the bits as-is)
[05:38:37] <Jartza> rest of those "magic" macros are just helpers for those
[05:42:28] <hackvana> nuxil: Welcome to /join #hackvana :-)
[05:42:56] <Fleck> spam...
[06:07:11] <hackvana> Fleck: If you say so. But you'd be surprised how many people in here are also in #hackvana.
[06:31:04] <Fleck> and spam again...
[06:32:09] <Lambda_Aurigae> no different from someone mentioning ##electronics or ##pic
[06:32:20] <Lambda_Aurigae> it just happens he sells things over there and many here use his services.
[06:32:30] <hackvana> Lambda_Aurigae: Could be that Fleck is bored and is just trolling me.
[06:33:01] <hackvana> Could also be that in saying that, I'm trolling him! (or her! I could be gender-neutral trolling!)
[06:33:37] <Fleck> ;p
[06:35:50] <Lambda_Aurigae> trolls are fun.
[06:35:55] <Lambda_Aurigae> I like to feed them.
[06:36:35] <Lambda_Aurigae> and these days, even if it is a him it might be a her,,,or versa visa.
[06:37:17] <Lambda_Aurigae> physically female but identifies as male so legally we gotta call it a him even though genetically it don't fit....
[06:37:47] <Lambda_Aurigae> I've run into that 3 times in the last month...two of them IRL and one on IRC
[06:38:44] <hackvana> Life's hard enough without dicking people around.
[06:39:39] <Lambda_Aurigae> then where's the fun?
[06:39:43] <Lambda_Aurigae> :}
[06:40:10] <Lambda_Aurigae> can't kick puppies, can't put alum in the candy anymore, can't feed the trolls....
[07:31:43] <cehteh> http://tinyurl.com/grwoam2 something fundamentally wrong there? i've seen a few capacitor power supplies but not exactly this way
[07:33:52] <Lambda_Aurigae> works but not particularly efficient.
[07:34:38] <cehteh> ah found one who does it exactly like this
[07:34:59] <Jartza> Fleck: actually, there's very helpful community also on #hackvana (yes, spam again) and even if you join, nobody forces you to buy anything ;)
[07:35:03] <cehteh> actually these are extremely efficent for low currents and *if* you can match them properly
[07:35:16] <Jartza> https://www.youtube.com/watch?v=mDK4Rb5d4Z4
[07:35:18] <Jartza> :)
[07:35:27] <cehteh> much more efficent than small transformers or switching ps
[07:35:35] <cehteh> (30mA there)
[07:35:44] <LeoNerd> Yah.. no good for dynamic load though
[07:36:25] <cehteh> yes
[07:36:48] <cehteh> i am quite aware of the negative aspects
[07:37:12] <Jartza> 51% flash free still
[07:37:37] <Jartza> not sure but it might just be possible to cramp some kind of plasma effect there or something
[07:38:23] <cehteh> mhm much higher rated zener and ldo will be better
[07:39:27] <cehteh> 15 or 18v zener and ldo which can handle that
[07:40:16] <cehteh> the only loss is then on the 47 ohms limiting resistor
[07:40:28] <cehteh> and ldo .. eh :D
[08:18:37] <Fleck> Jartza: that doesn't justify spaming! :D
[08:32:53] <nuxil> Fleck, spam ?
[08:33:19] <Fleck> ?
[08:33:30] <nuxil> why you keep saying spam
[08:33:57] <Fleck> meh, read above...
[08:34:34] <nuxil> 1st time you said spam.. was after hackvana posted a channel. which i asked about so dont see how that was spam.
[09:20:03] <cehteh> http://tinyurl.com/zudxx53 so how about that?
[09:37:12] <cehteh> aaahh .. Vp-p over the FET ..
[09:39:38] <Jartza> tcp/ip over fet
[09:41:59] <songweelee> Error: No device detected. Error 4109.
[09:42:01] <songweelee> please help me
[09:42:14] <cehteh> plug device in
[09:42:16] <songweelee> I've got the error.
[09:42:34] <songweelee> @derbis
[09:42:44] <songweelee> please help me!
[09:43:18] <Jartza> error: insufficient information provided
[11:38:03] <Jartza> hmm
[11:38:22] <Jartza> can't quite get the 3rd color bit working, darned
[11:50:23] <nuxil> i want to shift4 bits or something i think left. how can i do this in C? example i have a 16 bit unsigned int. like i have these bits.
[11:50:25] <nuxil> 1 1 1 1, 0 0 0 0, 1 1 1 1, 0 0 0 0
[11:50:31] <nuxil> and want them to become
[11:50:37] <nuxil> 0 0 0 0, 1 1 1 1, 0 0 0 0, 1 1 1 1
[11:50:48] <nuxil> and then back to the 1st again next shift
[11:50:59] <nuxil> ideas?
[11:51:46] <LeoNerd> >> 4 surely?
[11:51:53] <LeoNerd> and then << 4
[11:52:12] <nuxil> but lets assume i cant do rightshift
[11:52:38] <nuxil> or is that safe?
[11:52:51] <LeoNerd> Why are we assuming that? It's an odd restriction to make
[11:52:58] <LeoNerd> gcc is quite happy to rightshift
[11:53:38] <nuxil> oh.
[11:54:17] <Jartza> and AVR assembler has both left and right shifts
[11:54:19] <nuxil> i was unsure if the lsb got moved over to the msb etc. or whatever.
[11:54:21] <Jartza> with or without carry
[11:54:42] <LeoNerd> It's a shift, not a rotate
[11:54:45] <Jartza> gcc takes care of shifting through carry for 16/32 bits
[11:55:04] <nuxil> LeoNerd, nerd well. i need a rotate then ;)
[11:55:13] <nuxil> oh
[11:55:32] <Jartza> so you want to rotate separate bytes?
[11:55:40] <nuxil> yes
[11:56:03] <LeoNerd> Rotate is a little trickier, but can be done. new = (old >> 4) | (old << 12) if old and new are uint16_t
[11:56:50] <Jartza> nuxil: why have 16 bit variable then if you want to rotate separate bytes?
[11:56:52] <LeoNerd> unsigned is important to ensure it zero-extends rather than sign-extends when shifting right
[11:57:33] <nuxil> Jartza, cos i got 16 leds. 1 bit for each led :o
[11:58:02] <Jartza> if you had uint8_t it would be easy with inline asm
[11:58:04] <Jartza> asm volatile("swap %0" : "=r" (value) : "0" (value));
[11:58:30] <Jartza> that switches 4 LSB with 4 MSB
[11:58:36] <Jartza> and vice versa
[11:58:51] <Jartza> of course you could create a "magic" datatype, which is union
[11:59:45] <Jartza> typedef union { uint16_t word; uint8_t bytes[2]; } magic;
[12:00:30] <Jartza> then just define your variable as "magic leds;"
[12:01:09] <Jartza> then you can either access it as 16-bit or two bytes :)
[12:01:34] <Jartza> leds.bytes[0]; and leds.bytes[1];
[12:01:40] <Jartza> or leds.word;
[12:03:05] <Jartza> and then just swap each byte with inline asm :)
[12:03:14] <Jartza> if you want performance :P
[12:03:22] <nuxil> duude
[12:03:24] <nuxil> lol
[12:03:28] <nuxil> take it easy
[12:03:42] <Jartza> I am :D
[12:03:47] <Jartza> that is easy
[12:03:55] <Jartza> it's just code :D
[12:04:07] <nuxil> i can barly understand what << and >> does :p
[12:04:29] <LeoNerd> They're just bitshifts
[12:04:36] <nuxil> bare inmind im a C noob
[12:04:43] <LeoNerd> 00000001 << 1 gives you 00000010
[12:04:52] <LeoNerd> << 2 would give you 00000100 etc...
[12:04:56] <Jartza> 10000000 << 1 gives you 00000000 :)
[12:05:01] <Jartza> that's good to remember
[12:05:12] <Jartza> (unless you have 16-bit variable)
[12:07:42] <nuxil> so whats up with your 3rd color Jartza ?
[12:08:10] <Jartza> not 3rd color, 3rd color bit :)
[12:08:13] <Jartza> which makes 8 colors
[12:08:25] <Jartza> currently I only have 2 bits (4 colors)
[12:08:37] <Jartza> well the problem is, I have 3 usable pins on that MCU
[12:08:44] <Jartza> and I'm generating VGA :)
[12:09:00] <Jartza> pretty hard to get 3 color pins and sync signals :)
[12:09:35] <nuxil> yeah, i bet it is
[12:10:05] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxejduNm95Q3Q5blU/view
[12:10:08] <Jartza> this is the MCU :)
[12:10:08] <nuxil> i would not even know where to start on such a project :p
[12:10:21] <nuxil> wtf
[12:10:23] <Jartza> sot23-6
[12:10:32] <Jartza> 6 pins. 32 bytes of RAM. 512 bytes of flash.
[12:10:48] <nuxil> is that the tiny5?
[12:10:53] <Jartza> yes
[12:11:08] <LeoNerd> The surprisingly-accurately-named AT"tiny"5
[12:11:10] <Jartza> if you zoom into that pic, you see it says "T5" on it :)
[12:11:52] <LeoNerd> Unlike, say, the ATtiny1634 - a giant SOP-20 monster with two UARTs, an I2C slave, a USI, three timers, an ADC, ...
[12:11:54] <Jartza> nuxil: https://www.youtube.com/watch?v=xgG5ag5sG-o
[12:12:00] <Jartza> this is what I currently get out of that chip :D
[12:12:23] <Jartza> LeoNerd: yeah. but according to atmel's rules, it's lacking MUL, so it's tiny ;)
[12:12:32] <LeoNerd> Yah.. stupid
[12:12:37] <Jartza> because they don't have such thing as "atnormal" :D
[12:12:41] <Jartza> only tiny and mega
[12:12:44] <LeoNerd> There are less-featured ATmega chips, but since they /do/ have a MUL instruction, that counts
[12:12:50] <Jartza> yep
[12:12:58] <Jartza> atnomul and atmul
[12:12:59] * LeoNerd does not talk about XMEGA
[12:13:36] <Jartza> nuxil: as you can see, only 4 colors (black IS a color)
[12:14:37] <learath> er. black is a lack of color
[12:14:42] <learath> or colour if you are silly
[12:14:49] <nuxil> i still dont see any pong there :p
[12:15:51] <nuxil> what res is it outputting?
[12:16:07] <Jartza> well the vga signalling is 640x480@60Hz
[12:16:22] <Jartza> but of course I can't in any way draw pixels that fast
[12:16:29] <Jartza> VGA pixel clock is ~25.2MHz
[12:16:34] <Jartza> my attiny runs @12Mhz :D
[12:16:38] <nuxil> :)
[12:19:41] <Jartza> and of course I don't have any separate vga hardware
[12:19:51] <Jartza> I generate the whole signal using attiny
[12:20:09] <Jartza> which is all about timings. even on clock cycle miss is visible on screen
[12:20:36] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxaWFhTkd4cGg0TDg/view
[12:20:46] <Jartza> this is what it looks like if your timings are off even a tiny bit
[12:22:45] <nuxil> thats lots of noice there
[12:22:50] <nuxil> *noise
[12:23:01] <Jartza> that's with internal oscillator
[12:23:04] <Jartza> it's that "accurate"
[12:23:11] <Jartza> that's why I need external oscillator
[12:45:27] <jacekowski> Jartza: there are people that would disagree with you
[12:45:44] <jacekowski> Jartza: there a demo on the interwebs with someone doing vga + sound from single AVR
[12:45:50] <jacekowski> there is*
[12:46:28] <apo_> Jartza: oops :)
[12:47:50] <Mr_Sheesh> attiny actually
[13:01:01] <Jartza> jacekowski: if you're willing to live with the graphical glitches, then sure why not. but internal oscillator has a lot of jitter.
[13:01:18] <Jartza> and this is single attiny too :)
[13:01:21] <Jartza> it's just attiny5
[13:02:54] <Jartza> and 3 usable pins.
[13:04:12] <LeoNerd> Surely 4 if you knock out the reset fuse
[13:25:39] <Jartza> LeoNerd: 3 because I knocked our the reset
[13:25:53] <Jartza> vcc, gnd and oscillator are the other three
[13:25:59] <LeoNerd> Ohright, yes the oscillator
[15:42:25] <studdentt> is it doable to find the C code from the FLASH content of an avr ?
[15:52:03] <Jartza> why there would be any C-code in that flash
[15:52:10] <Jartza> probably just bianry
[15:52:12] <Jartza> binary
[15:53:16] <Jartza> that binary can be read of course, if there's no lock-bits set
[16:42:19] <Jartza> https://www.youtube.com/watch?v=8DOT-00G_0k
[17:47:11] <studdentt> Jartza: i know, from binary to assembler to C
[17:48:11] <Jartza> assembler to C might not be that easy
[17:49:40] <Jartza> or, it's not.
[17:49:44] <Jartza> let's forget the "might"
[17:49:48] <studdentt> Jartza : it have to be compiler specific
[17:50:11] <Jartza> sure. and platform specific. and much more.
[17:52:18] <Jartza> you basically need a decompiler. there are few of them but all that I know are hugely expensive.
[17:52:29] <Jartza> so it might be worth asking, if it's worth it? :)
[18:16:18] <Lambda_Aurigae> I have seen an x86 assembly to C converter..it was,,,,nasty.
[18:16:43] <Lambda_Aurigae> depending on what compiler was used in the first place it was either bad or very bad.
[18:16:46] <LeoNerd> They're generally not made for actually /understanding/ the C code
[18:16:51] <Lambda_Aurigae> yup.
[18:17:04] <Lambda_Aurigae> it would produce C that would compile, however.
[18:17:07] <LeoNerd> They're made to make *a* program that represents the original, such that you can recompile it for a different architecture, as a way of porting
[18:17:08] <Lambda_Aurigae> mostly.
[18:20:39] <Jartza> Lambda_Aurigae: https://www.youtube.com/watch?v=8DOT-00G_0k
[18:20:41] <Jartza> :D
[18:21:14] <Lambda_Aurigae> 8 colors?
[18:26:22] <Lambda_Aurigae> http://www.instructables.com/id/Heatless-cold-Toner-Transfer-for-PCB-Making/?ALLSTEPS
[18:34:24] <Jartza> Lambda_Aurigae: well, there's blue, green and red ;)
[18:34:54] <Jartza> yes, the blue color was just quick'n'dirty addition as the "center swirling image" was originally "drawn" for only 4 colors
[18:35:08] <Jartza> next I need to mod the engine to draw the 8 colors correctly
[18:35:13] <Jartza> but now I know I can get them out
[18:35:24] <Jartza> actually I get BW VGA out from single pin :D
[18:36:54] <Lambda_Aurigae> combining the sync with green or something?
[18:37:20] <Jartza> well, just some strange knowledge I gathered
[18:37:34] <Jartza> it seems 99% of the monitors actually XOR the vsync and hsync before sending it to "logic"
[18:37:48] <Lambda_Aurigae> yeah..have seen such things.
[18:37:52] <Jartza> I XOR them in the MCU end
[18:38:03] <Jartza> and just connect VSYNC to +5V
[18:38:26] <Jartza> but I also drive one color out from the same pin
[18:39:29] <Jartza> I could also drive 3 single-color VGA pictures if I wanted
[18:41:37] <Lambda_Aurigae> 3 monitors from one attiny5!!!!
[18:42:47] <Jartza> yea :D
[18:43:42] <Jartza> and powered with 4*1.5V battery? :)
[18:44:06] <Jartza> or single 1.5V battery and power booster (which is as big as MCU)
[18:47:34] <Jartza> the nice thing in B/W is that it doesn't actually need to be white
[18:47:46] <Jartza> you can pick any color you like just by changing few resistor values
[18:49:17] <Lambda_Aurigae> hmmm.
[18:49:27] <Lambda_Aurigae> digital pots controlled via spi?
[18:55:20] <Jartza> heh
[18:55:28] <Jartza> not really possible to add spi anymore :D
[19:00:58] <Jartza> maybe I'll just play around with the 8-color mode now
[19:03:27] <Jartza> but NOW is time for good night ;)
[19:07:19] <Lambda_Aurigae> nighters.
[21:56:59] <inflex> hrmm.. Tom_itx , can't seem to get my Attiny10s to program... signature comes up fine on avrdude but can't write data
[21:57:15] <inflex> avrdude: usbdev_send(): wrote 0 out of 1 bytes, err = could not detach kernel driver from interface 0: No data available
[21:57:15] <inflex> avrdude: stk500_send_mk2(): failed to send command to serial port
[22:12:12] <rue_bed> inflex, is that with toms programmer?
[22:21:14] <inflex> yes
[22:21:28] <inflex> maybe I've blown the bridge chip (using TPI )
[22:25:14] <xrlk> do you program a programmer with a programmer