#avr | Logs for 2016-01-02

Back
[01:01:26] <nuxil> so im a total C noob and i see something called "bit_is_set" which i belive is a macro ? right i see it used like if(bit_is_set (PINB, 2)) balh.. is that the same as doing if(PINB & (1 << PB2)) blah ??
[02:09:43] <rue_shop3> anyone know if there is a magic flag to get the uart to invert the serial data?
[02:09:44] <cehteh> yes
[02:10:02] <cehteh> i meant nuxil
[02:10:47] <cehteh> and iirc there is nothing to invert serial, when you find something tell me
[02:12:20] <rue_shop3> heh, hmm 74HC1G14
[02:15:11] <rue_shop3> I can make a sip out of a dip 7414 if I tie the first input high...
[02:17:53] <nuxil> cehteh, what?
[02:19:42] <rue_shop3> a) source a DIP 74LS04
[02:19:59] <rue_shop3> b) cut off pins 2, 8, 9, 10, 11, 12, 13
[02:20:12] <rue_shop3> c) fold back pin 14 over the bottom of the chip
[02:20:21] <rue_shop3> d) straighten pins 1, 3, 4, 5, 6, 7
[02:20:36] <rue_shop3> e) solder a wire strap from pin 14 to pin 1
[02:20:51] <rue_shop3> -- TADA a SIP 74LS2G04
[02:20:55] <rue_shop3> --
[02:21:37] <cehteh> nuxil: your bit_is_set question
[02:21:57] <nuxil> ahh.
[02:22:10] <nuxil> k. thx
[04:42:01] <rue_bed> nuxil, did yo uwork it out?
[06:40:54] <nuxil> rue_bed, yes
[11:56:41] <rue_house> #define SetBit(BIT, PORT) (PORT |= (1<<BIT))
[11:56:42] <rue_house> #define ClearBit(BIT, PORT) (PORT &= ~(1<<BIT))
[12:09:13] <nuxil> :)
[12:09:39] <nuxil> rue_house, so setbit sets it high and clearbit sets it low ?
[12:12:21] <nuxil> if the pin has 3 stage it might be confusign.. like high, low, high impedance. would it not be better to have the macros named. setHigh, SetLow, Disablepin,, or something like that?
[12:13:22] <LeoNerd> I'd call those DRIVE_LOW(), DRIVE_HIGH(), HIZ()
[12:13:33] <LeoNerd> I'd also name them in allcaps to remind people they're nonatomic macros
[12:14:14] <nuxil> nonatomic ? they dont blow up? :p
[12:14:32] <LeoNerd> As in, they operate across multiple statements
[12:14:39] <nuxil> ah
[12:15:38] <LeoNerd> #define DRIVE_LOW(P, BIT) do { DDR##P |= _BV(BIT); PORT##P &= ~_BV(BIT); } while(0)
[12:15:41] <LeoNerd> for example
[12:16:02] <nuxil> hehe
[12:16:36] <nuxil> no idea what that. do { DDR##P does
[12:17:02] <LeoNerd> do { .... } while(0) is a loop that executes exactly once
[12:17:13] <LeoNerd> ## is the preprocessor "paste" operator
[12:17:13] <nuxil> i tend to stay away from macros
[12:17:36] <LeoNerd> So e.g. if you did DRIVE_LOW(B, 2) it would expand to DDR##B which gets pasted together into DDRB
[12:17:59] <nuxil> ic
[12:20:25] <nuxil> LeoNerd, why do you need a loop if its only executed once ?
[12:22:23] <nuxil> nevermind my noob questions..
[12:22:24] <nuxil> :p
[12:23:55] <LeoNerd> if(cond) DRIVE_LOW(...);
[12:24:02] <LeoNerd> So as to make sure this thing doesn't berak
[12:24:03] <LeoNerd> break
[12:24:28] <LeoNerd> Without the loop, if the macro just expanded to two statements then the first would be condition but the second would not
[12:36:03] <rue_house> LeoNerd, well, post the full definitions then!
[12:36:15] <rue_house> dont just talk the code, write the code!
[12:37:16] <LeoNerd> I posted one.. the other two should be obvious from that
[12:38:50] <rue_shop3> no, you have to do it all out
[12:39:16] <rue_shop3> remember, people only copy and paste code, so if you dont post full code its not usable to anyone
[12:39:46] <Lambda_Aurigae> is that why windows is so bloated?
[12:40:04] <Lambda_Aurigae> and why windows 10 still has code(and vulnerabilities apparently) from windows 3.1?
[12:40:59] <Casper> it can't be possible
[12:41:28] <Casper> win3.1 was 16 bits, all 16 bits code is gone since win7 from what I read
[12:42:27] <Lambda_Aurigae> really?
[12:42:35] <Lambda_Aurigae> https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwilpvuq3ovKAhXERyYKHZYnApUQFggjMAA&url=http%3A%2F%2Fwww.computerworld.com%2Farticle%2F2523045%2Fmalware-vulnerabilities%2Fmicrosoft-confirms-17-year-old-windows-bug.html&usg=AFQjCNFQ0kZberWDIBVMppkSXnwKSI5u6A
[12:42:43] <rue_shop3> thats why all software is half working junk!
[12:43:04] <rue_shop3> ok, most software
[12:43:05] <Lambda_Aurigae> that's just the first one I found...from 2010..
[12:43:59] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxSW9YQ0lTcnlxbjg/view
[12:44:11] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxejduNm95Q3Q5blU/view
[12:44:24] <Casper> that one was for winnt, not win3.11
[12:44:52] <Jartza> Segment usage: Code : 119 words (238 bytes)
[12:44:55] <Casper> nt3.1 != win3.1
[12:44:56] <Jartza> :P
[12:45:05] <Jartza> still plenty of space for some effects? :)
[12:45:18] <Lambda_Aurigae> https://en.wikipedia.org/wiki/Windows_Metafile_vulnerability that one went from windows 3.0 to server 2k3
[12:45:20] <rue_shop3> I loved microsofts compaign about bash being a securrity vulnerability in linux
[12:45:55] <rue_shop3> how do you install linux on an xbox? just upload the linux font :)
[12:47:32] <Lambda_Aurigae> and the most common computer vulnerability....cousin BillyBob.
[12:48:15] <rue_shop3> hmm, almost a half hour in and nobody is here, guess no rootics class today
[12:48:36] <Lambda_Aurigae> rue_shop3, I only do my classes in the summer.
[12:48:43] <Lambda_Aurigae> too cold in the shed for winter classes.
[12:49:02] <Lambda_Aurigae> I do need to go fire the furnace up over there and do some work though..
[12:49:04] <Lambda_Aurigae> laters all.
[13:04:23] <nuxil> :)
[13:05:17] <nuxil> yay. got the pwm working for my led mirror :)
[13:06:08] <nuxil> I got some wireing nightmare here :p
[13:07:05] <nuxil> https://gyazo.com/0170324bd7fa8a3605f9bfb199604e8a
[13:07:06] <nuxil> hehe'
[13:08:08] <nuxil> 1 powerbutton,, 1 button for increaing and a button for decreasing the light ;)
[13:08:34] <cehteh> lol
[13:08:58] <cehteh> wtf did you do to mess that up so much?
[13:10:01] <nuxil> bought wrong diods :p
[13:10:14] <nuxil> rgb diods instad of standar blue ones
[13:10:17] <nuxil> lol
[13:10:29] <nuxil> these ones got 4 pins
[13:10:34] <cehteh> and?
[13:10:53] <cehteh> you control each individually?
[13:10:58] <nuxil> but idea is to use 6 8bit shift registers to control them
[13:11:04] <cehteh> ok
[13:11:19] <nuxil> cacading them
[13:11:34] <nuxil> *erm wireing them up in series
[13:12:29] <nuxil> and these shit diods got common anode instead of kathode. :\ so i need to use a pullup system
[15:00:35] <rue_house> heh
[15:00:46] <rue_house> did that on my fire alarm test panel
[15:01:19] <rue_house> common annode is good tho
[15:01:21] <rue_house> thats what you want
[15:01:25] <rue_house> chips drive low well
[15:03:21] <rue_house> 16 leds
[15:03:25] <rue_house> 3 colour each
[15:03:36] <rue_house> 48 leds
[15:03:51] <rue_house> if you charlieplex 2 wires you get 2 leds
[15:04:03] <rue_house> if you charlieplex 3 wires you get 9 leds
[15:04:07] <rue_house> er
[15:04:10] <rue_house> if you charlieplex 3 wires you get 6 leds
[15:04:30] <rue_house> if you charlieplex 4 wires you get 12 leds
[15:05:49] <rue_house> if you charlieplex 5 wires you get 20 leds
[15:08:12] <rue_house> if you charlieplex 6 wires you get 30 leds
[15:08:30] <rue_house> if you charlieplex 7 wires you get 42 leds
[15:08:36] <rue_house> hmm
[15:08:51] <rue_house> so you need to charlieplex 8 lines
[15:09:12] <rue_house> for 56 leds
[15:13:58] <Lambda_Aurigae> that would be one seriously complex charlie.
[15:36:54] <rue_shop3> ?
[15:37:03] <Casper> !
[16:09:06] <Jartza> hmmh yea
[16:09:44] <LeoNerd> charlieplexing beyond about 4 starts to seem silly
[16:10:02] <LeoNerd> At 3 wires you can drive a sequence of 74'595s as long as your arm
[16:10:38] <Lambda_Aurigae> yes, but you either have to drive them really fast or have a massive power supply to have a lot of LEDs lit at one time.
[16:10:39] <cehteh> where is the challenge :D
[16:11:03] <Jartza> well
[16:11:06] <Lambda_Aurigae> Jartza, here's a challenge for you!
[16:11:15] <Jartza> Lambda_Aurigae: I have another challenge already :D
[16:11:29] <Lambda_Aurigae> a pair of chips, running separately but listening on the same uart line.
[16:11:30] <Jartza> I now have jitter-free hsync+vsync + 2 colors out to vga from attiny5
[16:11:36] <Lambda_Aurigae> one chip running the columns
[16:11:37] <Jartza> I'm trying to get 3rd color still
[16:11:39] <Lambda_Aurigae> one chip running the rows.
[16:11:51] <Jartza> and currently I still don't use a single byte of the SRAM :)
[16:12:31] <Jartza> trying to get color bars
[16:13:35] <Lambda_Aurigae> kewl.
[16:15:05] <Jartza> btw
[16:15:08] <Jartza> https://drive.google.com/file/d/0B2dTzW9TMeBxaWFhTkd4cGg0TDg/view
[16:15:13] <Jartza> that's the jitter I'm talking about
[16:15:27] <Jartza> that's with internal oscillator, just tried that out too
[16:15:46] <Jartza> that's pretty much as stable as all internal oscillators in MCU are
[16:16:06] <cehteh> looking fine :D
[16:16:15] <Lambda_Aurigae> yeah.
[16:16:26] <Lambda_Aurigae> really need an onchip crystal dag nabbit!
[16:16:35] <Jartza> well, that's single frame captured with camera. in video you see the jitter crawls all over the picture (so it's not stable)
[16:17:36] <Jartza> what amazes me is how versatile the attiny5 timer actually is!
[16:18:00] <Jartza> I'm trying to see how that can be utilized better for this
[16:18:19] <Jartza> but it beats attiny85 timers hands down
[16:18:36] <cehteh> didnt i told ya :D
[16:18:56] <cehteh> less components on the die, less noise
[16:18:57] <Jartza> I don't know. quite fun chip for sot23
[16:19:25] <cehteh> and prolly bigger structures/older process, but not sure about that
[16:20:01] <Jartza> btw. did I tell you how I fixed the jitter? :D
[16:20:19] <Jartza> with single timer and using "no sram"
[16:20:32] <Jartza> I set timer interrupt, nothing fancy in there
[16:20:43] <Jartza> the ISR never returns
[16:21:04] <Jartza> "so, you get 2 bytes of crap (return address) to the stack" you tell me? :)
[16:21:05] <cehteh> has the tiny power reduction registers to turn unused parts off? tried that?
[16:21:06] <Jartza> I don't
[16:21:15] <Jartza> cehteh: yes it does
[16:21:46] <Jartza> so. at the end of the ISR, I set stack pointer to point... well... to stack pointer pointer address :D
[16:21:47] <cehteh> i wonder that SRAM generates so much jitter
[16:21:50] <Jartza> and re-enable ISRs
[16:21:53] <Jartza> and go to sleep
[16:22:05] <cehteh> with dram it might be expected .. but i thought sram is pretty static
[16:22:13] <Jartza> cehteh: it's not SRAM that generates jitter, it's the internal oscillator
[16:22:18] <cehteh> ah
[16:22:26] <Jartza> with external oscillator there's no jitter
[16:22:27] <cehteh> eh moment
[16:22:33] <cehteh> you saied timer
[16:22:37] <Jartza> but AVR interrupt always have jitter
[16:22:56] <Jartza> because instruction currently being processed is being finished before jump to ISR
[16:23:02] <Jartza> and instructions take 1-3 cycles
[16:23:15] <cehteh> yes
[16:23:23] <Jartza> so you have that few cycle jitter in ISR. except when waking up from sleep with timer :)
[16:23:37] <Jartza> that's jitter free because you're not running any instructions in sleep
[16:23:38] <cehteh> calling isr itself takes a few cycles too
[16:23:43] <Jartza> true
[16:23:49] <Jartza> but there's no jitter, that time is always the same
[16:23:55] <LeoNerd> that's predictable latency
[16:24:00] <Jartza> yep
[16:24:06] <LeoNerd> predictable things can be accounted for
[16:24:14] <Jartza> so. when ISR happens, attiny stores the "return address" to SPL and SPH :D
[16:24:17] <cehteh> solution: use only one-cycle instructions
[16:24:21] <LeoNerd> Cute
[16:24:22] <Jartza> so my stack points to "whereever", but I don't care
[16:24:28] <Jartza> as my ISR is my "main loop"
[16:24:32] <LeoNerd> :)
[16:24:59] <Jartza> pretty cool I think
[16:25:46] <Jartza> cehteh: there's actually plenty of 2 cycle instructions in AVR
[16:26:07] <Jartza> so their advertisement "1 MIPS per MHz" is quite bollocks in real life :D
[16:26:43] <Jartza> and reading byte from flash takes 3 cycles
[16:27:07] <cehteh> 1 mips of nops
[16:27:14] <Jartza> cehteh: https://drive.google.com/file/d/0B2dTzW9TMeBxQy01WGhEbjhMUXc/view
[16:27:18] <Jartza> that's with external oscillator
[16:28:44] <cehteh> there is no lock instruction at avrs .. some oher µC have that 'run the next n (for very small n) instructions uninterruptable'
[16:29:08] <cehteh> that would often far nicer than cli/sei
[16:32:21] <Jartza> http://pastie.org/10666310
[16:32:24] <Jartza> that's where my ISR ends
[16:52:58] <rue_shop3> would you like to use a PIC that divides the crystal by 4 and then uses that as a cycle for multi-cycle instructions?
[16:53:49] <rue_shop3> maybe an 8051 that divides the clock rate by 8?
[16:54:00] <rue_shop3> and takes up to 8 cycles for an instruction?
[16:55:07] <Lambda_Aurigae> I have 8052 chips that are mostly single cycle instructions like AVR
[16:56:23] <LeoNerd> Jartza: So, what's so great about the attiny5 timer?
[17:00:58] <studdentt> is there a way to reset a uC ? ive got a device here that have a chaning signature each to time i try to program with avrdude
[17:01:07] <rue_house> Lambda_Aurigae, maybe after you set the flag
[17:01:10] <Jartza> LeoNerd: first of all, it's 16 bit. it has input capture unit with noise canceler, frequency generator, event counter... whatnot
[17:01:38] <Jartza> studdentt: sounds like bad connection or too high speed
[17:01:43] <rue_house> Lambda_Aurigae, tho I dont think its single clock, the cycles are still a division of the clock freq
[17:01:44] <Lambda_Aurigae> rue_bed, ds89c450...they run single cycle like AVR by default...they can be set to run div/8 like older 8051 though.
[17:01:53] <rue_house> they just take it from 4 to 2 or soemthing
[17:02:01] <Lambda_Aurigae> it's an high speed 8052 core.
[17:02:05] <rue_house> yea
[17:02:31] <Lambda_Aurigae> studdentt, signature should never change...it's hard coded.
[17:02:49] <Jartza> anyhow, trying to get this "main code" smooth now
[17:02:49] <rue_house> I have some that went obsolete, they had a serial bootloader built into them
[17:03:01] <Jartza> and trying some tricks I learned from avrfreaks :P
[17:03:09] <studdentt> Jartza: connection is fine and the speed ..i use the same settings when i program another uC ofsame type
[17:03:19] <Jartza> to get vga with 8 colors out from 3 pins :D
[17:03:23] <studdentt> Lamba_Aurigae: yes,
[17:03:37] <Lambda_Aurigae> rue_bed, yeah...ds89c420 or something like that...predecessor...the ds89c450 I think is still current and has the serial bootloader hardcoded.
[17:09:22] <LeoNerd> Jartza: Most 16bit AVR timers have those
[17:10:49] <Jartza> LeoNerd: attiny85 doesn't, but tiny5 does.
[17:16:23] <LeoNerd> Huh really? Maybe I misremember theb
[17:16:27] <LeoNerd> then
[17:16:43] <Jartza> https://scontent-ams3-1.xx.fbcdn.net/hphotos-xfl1/v/t1.0-9/11934937_10153119860957621_880102855444730137_n.png?oh=bf200625eb4eae4cb39e0546007f9d7c&oe=571AB421
[17:17:00] <Jartza> LeoNerd: attiny85 only has 2 8-bit timers
[17:18:54] <LeoNerd> Oh, hmmm... I was thinking of the attiny84, which I often use
[17:19:02] <LeoNerd> That has one 8 and one 16
[17:19:35] <studdentt> Jartza: or something broke inside the chip causing bitflips ?
[17:42:01] <Jartza> LeoNerd: yeah, seems so
[18:48:44] <Jartza> night all!
[22:07:33] <ali1234> what is this supposed to do: http://paste.ubuntu.com/14381649/
[22:08:52] <Tom_itx> waste time
[22:09:25] <ali1234> that's what i thought, thanks
[22:09:57] <Tom_itx> nop would be a better way
[22:10:02] <ali1234> yeah
[22:10:22] <ali1234> why even use two registers for this?
[22:10:27] <Casper> mov/add/sub is also 1 cycle right?
[22:10:48] <ali1234> maybe both those registers need to be 0 for the next bit of code
[22:10:58] <Casper> or just wastefull
[22:11:19] <ali1234> is this something a compiler would emit?
[22:11:48] <Casper> doubt so, dosen'T look like it
[22:11:54] <Casper> specially the sub part
[22:12:15] <Casper> then change to add r20 r20
[22:12:28] <Casper> which make no sense to me to do it 2 ways...
[22:14:52] <Casper> ldi r20 0x00; add r20 r20 .... would have been more optimal... beside, if it was GCC, chance is that it would simply have used the already zeroed register... I beleive it is r0
[22:15:07] <Casper> so it would have done add r0, r0
[22:15:16] <Casper> but more likelly just issued a nop
[22:17:49] <Casper> add, ldi, sub, mov and nop are all 1 cycle long... I see no point of doing that mess except to make code easier to reverse engineer
[22:19:32] <ali1234> wait hang on a minute, i am dumb
[22:20:18] <ali1234> it can jump over the ldi: http://paste.ubuntu.com/14381895/
[22:21:10] <Tom_itx> so it either loads it with 1 or 0
[22:28:28] <ali1234> ah
[22:28:45] <ali1234> got it. gcc emits this code if you do foo %= 200;
[23:10:52] <Casper> hmmm
[23:11:08] <Casper> now... to figure out how to extract the data from a string...
[23:46:12] <Casper> hmmm
[23:47:04] <Casper> on avr, is there a binary string to 64 bits integer? as in a string of like "000110000011100000000011000011010010" converted to a 64 bits...
[23:47:16] <Casper> or will I have to make my own?
[23:47:29] <Casper> (same on pc side)