#avr Logs

Oct 31 2017

#avr Calendar

01:15 AM day__ is now known as daey
05:09 AM nuxil: mornings
05:09 AM nuxil: how ya doing today.
05:10 AM polprog: morning
05:10 AM nuxil: hi polprog
05:13 AM nuxil: so. im still trying to figure out how to make a square wave generator with adjusteble frequense and duty cycle
05:13 AM nuxil: but i have a hard time getting my head around this.
05:13 AM polprog: what do you have already?
05:13 AM nuxil: lol. not much.
05:13 AM nuxil: i not sure how to setup the time.
05:13 AM nuxil: remember im a noob
05:14 AM nuxil: https://pastebin.com/0k0sieRU this is what i got so for.
05:14 AM polprog: what chip do you have?
05:14 AM nuxil: atiny85
05:14 AM nuxil: read my paste questions pls :D
05:14 AM nuxil: questions in the paste
05:15 AM nuxil: the part // So to get a 50% duty
05:16 AM Lambda_Aurigae: start with the adjustable part....you wanting to use a potentiometer for it?
05:16 AM nuxil: yea
05:16 AM nuxil: 2
05:16 AM Lambda_Aurigae: say, 100K or 150K ohm pot.
05:17 AM Lambda_Aurigae: so you want to vary the duty as well as the frequency?
05:17 AM nuxil: one for freq and one for duty cycle
05:17 AM Lambda_Aurigae: ok...so start with two.
05:17 AM Lambda_Aurigae: I like 150K ohm myself.
05:17 AM Lambda_Aurigae: tie one side to VCC, one side to GND, and the center tap to an ADC input on the microcontroller.
05:18 AM Lambda_Aurigae: read said ADC...or ADCs if doing multiple.
05:18 AM nuxil: should i not use AIN0 and AIN1 ?
05:18 AM Lambda_Aurigae: get that going right first.
05:18 AM Lambda_Aurigae: whatever two analog pins you need to use.
05:18 AM Lambda_Aurigae: if this is an ardweeny project I'm done here.
05:18 AM nuxil: lol no
05:18 AM Lambda_Aurigae: what microcontroller are you using?
05:18 AM nuxil: i dont have a ardweeny
05:18 AM nuxil: atiny85
05:19 AM Lambda_Aurigae: that's gonna be tight but doable.
05:19 AM Lambda_Aurigae: so, use the two analog inputs to read the POTs
05:19 AM polprog: AIN0 and AIN1 are analog comparator pins, not ADC pins
05:19 AM Lambda_Aurigae: get that working first....send the data over uart/usart/usi
05:19 AM nuxil: yea that was the idea
05:20 AM polprog: you have to use the adc
05:20 AM Lambda_Aurigae: let me grab the tiny85 datasheet
05:20 AM polprog: http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf
05:20 AM nuxil: umm hold on. but i cant send data over. i can only update the chip. i dont have a proper "chip burner" or whatever you call it. i use my raspberry pi to uploade code to it.
05:20 AM Lambda_Aurigae: I got it...just had to get there.
05:21 AM Lambda_Aurigae: that has nothing to do with sending data back to the PC/rPI
05:22 AM Lambda_Aurigae: tiny85 is gonna be hard to troubleshoot and test with.
05:22 AM nuxil: yea.
05:22 AM nuxil: i know
05:22 AM nuxil: cos i use this method to "burn" the chip http://www.instructables.com/id/Programming-the-ATtiny85-from-Raspberry-Pi/
05:23 AM Lambda_Aurigae: again,,,has nothing to do with sending data back,,,or troubleshooting.
05:23 AM nuxil: i gonna buy proper equipment
05:23 AM polprog: no you dont
05:23 AM polprog: you can do all the stuff with rapsery pi
05:23 AM polprog: raspberry*
05:23 AM nuxil: oki.
05:23 AM polprog: you use SPI to program the chip and UART [serial] for communication
05:23 AM Lambda_Aurigae: I would get a different chip to play with though.
05:24 AM nuxil: i only got the 85
05:24 AM Lambda_Aurigae: polprog, unfortunately, the attiny85 has a USI,,,not UART...much more difficult.
05:24 AM polprog: Lambda_Aurigae: ouch
05:24 AM nuxil: so i have to work with what i got :)
05:24 AM Lambda_Aurigae: I'm looking, I'm looking.
05:25 AM Lambda_Aurigae: might be easier to do a soft-uart....
05:25 AM Lambda_Aurigae: either way it's gonna be a bitch because you also need a crystal for that.
05:25 AM Lambda_Aurigae: or an external clock source.
05:26 AM Lambda_Aurigae: is this a homework project or something?
05:26 AM Lambda_Aurigae: that you have to use the tiny85?
05:26 AM nuxil: no homework. its a personal project
05:27 AM Lambda_Aurigae: then I would get/buy/steal/acquire something larger that has a real USART on it for testing/learning
05:27 AM nuxil: my project is to make a simple squar wave function generator.
05:27 AM Lambda_Aurigae: otherwise you really have no way of knowing if you are reading the ADC correctly.
05:28 AM polprog: yes, there are juts too many unknown factors
05:28 AM nuxil: cant i get the adc done 1st then include some pwm testcode the "mirrors" the Ain0?
05:28 AM Lambda_Aurigae: you need to read the ADC,,,twice,,,once for each POT...
05:28 AM polprog: i tould you ain0 is not for reading analog values
05:28 AM Lambda_Aurigae: how are you going to see if you are reading the ADC correctly?
05:28 AM Lambda_Aurigae: AIN0/1 is analog comparator...not analog input.
05:29 AM nuxil: hmm
05:29 AM Lambda_Aurigae: you have ADC1, 2, and 3
05:29 AM Lambda_Aurigae: physical pin 7, 3, 2 on the dip package
05:29 AM Lambda_Aurigae: guessing you haven't actually read the datasheet yet?
05:30 AM nuxil: but if i use internal vcc as ref for ain0 ?
05:30 AM polprog: no
05:30 AM nuxil: Lambda_Aurigae, i have the datasheet
05:31 AM nuxil: im reading it. but its soo much to understand when youre a noob :p
05:31 AM polprog: analog comparator tells you if ain0 is highver/lower voltage than ain1 and vice versa
05:31 AM Lambda_Aurigae: pin 6 is going to be your output for pwm
05:31 AM nuxil: ahh.. and i guess it only triggers on positive edge :p
05:31 AM polprog: you cannot know that ain0 is X volts, you only know if its bigger or smaller than ain1
05:31 AM Lambda_Aurigae: or pin 5...
05:32 AM Lambda_Aurigae: which happens to kill the ain0/1 pins which are the same two.
05:32 AM polprog: nuxil: do you understand the difference between analog comparator and analog-digital converter?
05:37 AM nuxil: analog comparator basically a opamp.
05:37 AM eichiro_ is now known as eichiro
05:37 AM Lambda_Aurigae: pretty much..
05:37 AM Lambda_Aurigae: ADC actually can read a voltage between 0V and AREF(usually VCC) and convert that to a number.
05:37 AM nuxil: yea. in a set resolution.
05:37 AM Lambda_Aurigae: analog comparator just says,,,high/low compared to a reference point.
05:37 AM Lambda_Aurigae: so, unless you have a way of changing that reference point multiple times and re-reading, then the comparator is useless for reading a POT
05:37 AM Lambda_Aurigae: you use the ADC.
05:37 AM Lambda_Aurigae: read that section of the datasheet.
05:37 AM Lambda_Aurigae: then reread it.
05:37 AM Lambda_Aurigae: then play with it.
05:37 AM polprog: that's how you learn
05:37 AM Emil: wat
05:37 AM Emil: analog comp is opamp without feedback
05:39 AM Lambda_Aurigae: Emil, we are talking about the one built into AVR
05:39 AM Emil: I know, just saying :D
05:39 AM Lambda_Aurigae: and why it isn't useful for reading a POT for variable input.
05:39 AM polprog: i dont know how they implemented a comparator in the avr but they know their shit.
05:39 AM polprog: and they drawn it as a comparator symbol, it doesnt have to be an opamp
05:40 AM Emil: nuxil: the adc prescaler is for the adc clock
05:40 AM Lambda_Aurigae: but, an opamp can do the same thing and it's a "valid" comparison....more or less.
05:40 AM Emil: nuxil: the clock must be <=1MHz
05:41 AM nuxil: must ?
05:41 AM Emil: for best time-accuracy, 100-125kHz
05:41 AM nuxil: i dont need huge presition
05:42 AM nuxil: *precision
05:42 AM Lambda_Aurigae: back to the problem at hand...first, learn how to read the POT with the ADC
05:42 AM Lambda_Aurigae: second, learn how to generate PWM of different frequencies and duty cycles using timer0
05:42 AM Emil: then you can use 16 if your clock is 16MHz
05:42 AM Lambda_Aurigae: third, put the two together.
05:43 AM Emil: nuxil: what hardware are you on?
05:43 AM Lambda_Aurigae: Emil, I'm betting his clock is 1MHz...well, 8MHz with div8 turned on.
05:43 AM Lambda_Aurigae: unless he has been playing with fuses.
05:43 AM Lambda_Aurigae: or does tiny85 not have div8?
05:43 AM Lambda_Aurigae: it's been a while since I screwed with those.
05:44 AM Lambda_Aurigae: seems it does...so likely 8MHz internal RC oscillator with DIV8 on
06:26 AM Emil: nuxil: what is your hardware?
06:26 AM Emil: Bare ATTINY85?
06:59 AM nuxil: yes
07:18 AM Emil: Okay
07:18 AM Emil: google "avr fuse calculator"
07:19 AM Emil: and select attiny85 and disable division by 8
07:19 AM Emil: Then your system clock will be around 8MHz
07:19 AM Emil: Alternatively you can change the scaler in code
07:20 AM Emil: So you know the system frequency and the datasheet says okay, 100kHz-1MHz clock for ADC
07:20 AM Emil: you select your prescaler so that the clock is between that
07:20 AM Emil: For 8MHz, set the prescaler to 8
08:00 AM nuxil: man. there is a lot to read.
08:00 AM polprog: yeah, but it's worth it
08:01 AM nuxil: so.. im read a bit about the adc. cant say i understand it all tho. far from it :p.
08:01 AM nuxil: anywho. am i on the right track ?
08:01 AM nuxil: https://pastebin.com/aUA9bYbF
08:01 AM nuxil: with the adc stuff
08:02 AM polprog: looks good,
08:02 AM polprog: if you have the bitmasks right
08:02 AM polprog: there are code examples in the datasheet
08:03 AM nuxil: well.
08:03 AM nuxil: im usure if i should do this result_adc2 = (high<<8) | low & 0xff; or just result_adc2 = (high<<8) | low
08:05 AM enh: hi
08:05 AM polprog: nuxil: i found an example where a 16 bit int is used
08:06 AM polprog: uint16_t val = ADCL | (ADCH << 8);
08:06 AM polprog: (in fact it was just 'int' but i dislkie this ambiguity)
08:06 AM polprog: dislike*
08:06 AM nuxil: ah. nice
08:09 AM Emil: polprog: stop
08:09 AM Emil: just uint16_t=ADC
08:10 AM polprog: Emil: not my code
08:10 AM Emil: I mean, the compiler _probably_ (_hopefully_) optimises it
08:10 AM polprog: nice tip though
08:10 AM polprog: never knew libc gives ADC register
08:10 AM Emil: polprog: I know, but you know enough to help them directly ;)
08:10 AM nuxil: hmm the manual says.
08:10 AM nuxil: When ADCL is read, the ADC Data Register is not updated until ADCH is read
08:10 AM nuxil: so i need to do it like i did i think
08:10 AM Emil: nuxil polprog for every 16-bit register the compiler automatically generates the proper code
08:11 AM polprog: nice
08:11 AM LeoNerd: gcc will handle that properly for you. You don't need to think about it
08:11 AM Emil: polprog: or did you always do TCNT1H=..., TCNT1L=...? :D
08:12 AM polprog: not really
08:12 AM polprog: heh
08:13 AM Emil: polprog: the correct order of handling the is mentioned in the datasheet
08:13 AM Emil: temp register is used
08:13 AM uramhoaH: isn't the ADC output usually a signed value?
08:13 AM Emil: uramhoaH: lolwat no
08:13 AM uramhoaH: don't you want int16_t ?
08:13 AM uramhoaH: u sure?
08:13 AM Emil: polprog: but you have to keep in mind that the access isn't atomic iirc
08:13 AM Emil: uramhoaH: I'm 100% sure
08:13 AM Emil: uramhoaH: mate really wat :D
08:13 AM polprog: if i wanted atomic access i have my ways
08:13 AM Emil: signed ADC value do you even microcontroller bro? :D
08:14 AM polprog: mfw he has built and ADC that can go below AREF
08:14 AM * uramhoaH shocks Emil with 3.3 volts
08:14 AM Emil: mfw I want a differential ADC that handles negatives too T.T
08:14 AM Emil: polprog: also
08:14 AM polprog: and i want a cadilac eldorado
08:14 AM Emil: you meant "below 0 reference"
08:14 AM Emil: ;)
08:14 AM polprog: but i cant get one
08:14 AM thardin: Emil: ads131a04 can
08:15 AM Emil: polprog: y u bully
08:15 AM nuxil: Emil, but if i just read do uint16_t=ADC . will the register update ? cos the manual says i need to read adcl before adch. will it not be stuck on 1 value if i use readout ADC ?
08:16 AM Emil: nuxil:
08:16 AM Emil: I and LeoNerd already said it
08:16 AM Emil: it works just fine
08:16 AM uramhoaH: Emil my function for reading the ADC outputs int16_t
08:16 AM Emil: it's specified to work just fine
08:16 AM uramhoaH: on xmega
08:16 AM * uramhoaH slaps Emil with a fish
08:16 AM Emil: uramhoaH: does it handle negative values?
08:16 AM Emil: is it differential?
08:16 AM uramhoaH: define "handle"
08:17 AM Emil: If so, then you have a bug in your code and should update to uint16_t
08:17 AM Emil: if not so*
08:17 AM uramhoaH: adc_chan->CTRL = ADC_CH_GAIN_1X_gc | ADC_CH_INPUTMODE_SINGLEENDED_gc;
08:17 AM uramhoaH: "single ended"
08:18 AM Emil: uramhoaH: then you should definitely change it to uint16_t.
08:18 AM Emil: If the bits are less than 16 then you don't encounter the bug
08:18 AM Emil: since the sign bit doesn't change
08:18 AM Emil: but the result is definitely unsigned
08:20 AM uramhoaH: what if you're wrong ;P~
08:21 AM Emil: I microcontroller bro ;)
08:21 AM Emil: uramhoaH: but I mean
08:21 AM Emil: since you don't have 16 bits in the build in adc
08:21 AM Emil: you won't encouter the bug
08:23 AM uramhoaH: do you even xmega, bruh
08:26 AM uramhoaH: adc->CTRLB = ADC_CONMODE_bm | ADC_RESOLUTION_12BIT_gc;
08:26 AM uramhoaH: signed 12bit result
08:26 AM Emil: that's unsigned
08:26 AM Emil: unless you have differential that can handle negatives
08:27 AM Emil: Or if you can go below 0 reference
08:27 AM uramhoaH: it can (and does) go below 0
08:27 AM uramhoaH: when it's noisy enough
08:27 AM Emil: oh that's nice
08:27 AM Emil: then it's signed of course
08:27 AM Emil: for standard tinys and megas it's single ended
08:27 AM Emil: from 0 to reference
08:27 AM uramhoaH: this is single ended too! >:(
08:28 AM Emil: but it goes to negative!
08:28 AM uramhoaH: so wut
08:28 AM Emil: also
08:28 AM uramhoaH: it uses 1 adc pin
08:28 AM Emil: I know I know :D
08:28 AM Emil: You are misinterpreting me
08:28 AM Emil: Both are single ended
08:28 AM Emil: but xmegas can go below 0 reference apparently
08:29 AM Emil: wait
08:29 AM Emil: wtf
08:29 AM uramhoaH: the result can be given to you either in signed or unsigned format (if you drop the ADC_CONMODE_bm)
08:29 AM Emil: I'm googling now
08:29 AM Emil: and it says that your input voltage can't be negative
08:29 AM uramhoaH: it shouldn't
08:29 AM uramhoaH: but noise is naughty
08:30 AM Emil: oh it can but very limited
08:59 AM polprog: https://spectrum.ieee.org/tech-history/silicon-revolution/chip-hall-of-fame-atmel-atmega8
09:06 AM Emil: polprog: does that article cut short?
09:13 AM polprog: it's a bit short yeah
10:02 AM nuxil: hmm im doing something wrong with my code.
10:02 AM rue_mohr: if you dont know what it is, you didn't write it properly
10:03 AM rue_mohr: did you write your whole thing and then run it hoping it would work?
10:04 AM nuxil: i do a simple test with this code. https://pastebin.com/eHUL5Wiy and use a pot meter of 100k connected to vcc, gnd and adc2. however. pb0 is showing me 2.5v on the pin with my multimeter. adjusting the potmeter does not change anything :\
10:04 AM rue_mohr: looks like you set it to an ouput
10:04 AM nuxil: its suppose to go low/high when adc is above /below midpoint.
10:05 AM nuxil: im not sure what im doing wrong here.
10:05 AM rue_mohr: do you have working code to trasmitt over serial
10:06 AM nuxil: rue_mohr, its atiny85 chip, and i upload the code with some 1/2 desent setup using a rasperypi.
10:06 AM nuxil: so i cant do that
10:06 AM rue_mohr: if you rake your adc code into an init() and measure() fn, you can nonally test them, but drag them over to other programs
10:06 AM nuxil: init() =
10:07 AM nuxil: awedreenow stuff
10:07 AM nuxil: i dont use that
10:07 AM polprog: you make a procedure clled adcInit() or something like that
10:07 AM nuxil: :p
10:07 AM polprog: sticking all your shit in main() is ardweeny stuff :P
10:07 AM rue_mohr: nuxil, write code that dosn't work
10:08 AM nuxil: rue_mohr, yea i know.. thats why i ask for help what i am doing wrong.
10:08 AM rue_mohr: if (result_adc2 > 32767)
10:08 AM rue_mohr: now
10:08 AM rue_mohr: you do know its a 10 bit adc right?
10:08 AM polprog: i was about to pint that out
10:08 AM nuxil: man.
10:08 AM LeoNerd: Mmmmm pint
10:09 AM nuxil: someone told me to use result_adc2 = ADC; instead of result_adc2 = ADCL | (ADCH << 8); :p
10:09 AM rue_mohr: recyclable code is a good idea
10:09 AM LeoNerd: That makes no difference
10:09 AM polprog: yes because you need 16 bit int to hold a 10 bit value
10:09 AM LeoNerd: The _result_ is a 10bit value in either way
10:09 AM polprog: they dont make 10 but registers
10:09 AM polprog: 10 bit*
10:09 AM rue_mohr: nuxil, 10 bits goes from 0-1023
10:09 AM LeoNerd: It ranges from 0 to 1023; so half of it is 512
10:09 AM LeoNerd: (Or you could set the right-align bit)
10:10 AM polprog: the cpu did exactly what you told it to do ;)
10:10 AM polprog: PEBKAC
10:10 AM rue_mohr: so, you can never get 1024-65535 from a 10 bit value
10:10 AM nuxil: i see now.
10:11 AM rue_mohr: I suppose you could if it were a floating point value, but I'm going to pretend that option dosn't exist
10:11 AM rue_mohr: nuxil, my point, is that you didn't write the adc code seperatly and test it to know if it worked in the first place
10:11 AM rue_mohr: for all you know, it still dosn't
10:13 AM rue_mohr: I suggest writing either a simple pwm or serial transmitter, testing that to make sure it works, and then writing your adc values to it to see if you get what you expect, because you will know the serial/pwm works, it limits the scope of your problem to less than YOUR WHOLE PROGRAM :)
10:13 AM rue_mohr: aaaaaaaaaaaaaaaaaand you can recycle the code
10:14 AM rue_mohr: rue_mohr, hey
10:14 AM rue_mohr: what?
10:14 AM rue_mohr: he's Cing now
10:14 AM rue_mohr: :/
10:15 AM rue_mohr: I wonder if he can work out which channel is which
10:16 AM rue_mohr: is there an avr with mixed up adc channels or was that just PICs?
10:16 AM rue_mohr: I remmeber a wrong datasheet
10:16 AM rue_mohr: having to do an evil software channel number correction
10:17 AM Jartza_ is now known as Jartza
10:21 AM rue_mohr: https://pastebin.com/ubmbdHDz
10:21 AM rue_mohr: nuxil,
10:21 AM rue_mohr: ITS THE CLOSEST i CAN FIND AT TEH MOMENT
10:21 AM rue_mohr: pff caps
10:24 AM nuxil: i will recycle your code :D
10:24 AM rue_mohr: its for a t13
10:24 AM rue_mohr: milage may varry
10:26 AM nuxil: i have barly messed around with the atiny85. its the 1st chip i try to work with.
10:26 AM nuxil: <- super noob :D
10:27 AM rue_mohr: the mega328 is large and cheap and comes ready on a circuit board for you
10:27 AM nuxil: i see cool stuff people do with it on YT
10:27 AM rue_mohr: they would be doing cool stuff with any chip
10:28 AM rue_mohr: even if it came out of a doritos bag, thats just cause of who they are
10:28 AM polprog: some people run doom on TI calculators
10:28 AM polprog: it's not about the chip but about the idea
10:28 AM rue_mohr: and the gumption to press thru getting it to happen
10:29 AM nuxil: its amazing how much music people can get into a example atiny9 .. "a bit old video" https://hackaday.com/2012/08/14/making-chiptunes-with-32-bytes-of-ram/
10:29 AM nuxil: chiptune music rocks :p
10:29 AM renn0xtk9: abnybody has experience with stm32 here? I am trying to use virtual com port as in the example of ST, but don't figure out how it wokrs
10:29 AM rue_mohr: nuxil, to your favor, you didn't come here asking what to buy and how to start, your actaully banging your head against it, which is good
10:30 AM nuxil: :)
10:30 AM rue_mohr: renn0xtk9, depends what system your using, not done any software serial on an stm32
10:32 AM rue_mohr: I use libopencm3
10:32 AM renn0xtk9: rue_mohr basically I have everything compiled( their example) the only thing is, those #$%#$@^ do provide an "example" wiht an empty main ..
10:33 AM renn0xtk9: I don't know how I should trigger the sending of data i.e. and how to prerpare the data in the first place
10:33 AM renn0xtk9: i.e (if I should use the buffer of the usart
10:34 AM rue_mohr: renn0xtk9, you want serial or specifically software serial?
10:34 AM rue_mohr: http://paste.debian.net/993599/
10:35 AM renn0xtk9: rue_mohr I want virtual com port, so serilal over the usb
10:35 AM rue_mohr: geez, do I EVER update the comments in my code!@#?
10:35 AM rue_mohr: ooh
10:35 AM renn0xtk9: yeah I think this is purely serial
10:35 AM rue_mohr: not done it
10:35 AM renn0xtk9: not over USB
10:35 AM renn0xtk9: okay
10:36 AM rue_mohr: I use usb/serial chips cuase they dont screw up
10:36 AM rue_mohr: and processor overhead
10:36 AM nuxil: rue_mohr, i see NOP(); in your code. i never seen it before and i guess it means no operations. any point in having it there at all ?
10:36 AM rue_mohr: yes
10:37 AM rue_mohr: the compiler will 'remove useless code' sometimes
10:37 AM rue_mohr: for(i=0; i < 254; i++ );
10:37 AM rue_mohr: might get completely removed
10:37 AM rue_mohr: if you put a nop in it, it wont
10:38 AM nuxil: ah. oki.
10:38 AM nuxil: thanks.
10:38 AM rue_mohr: also, while(1); is a jump to jump instruction
10:38 AM rue_mohr: jump is a 2 cycle instruction
10:38 AM rue_mohr: so, an interrupt has to wait
10:38 AM rue_mohr: if it hits a 1 cycle nop, its half the wait
10:38 AM nuxil: oh. thatas nice
10:38 AM nuxil: *thats
10:39 AM thardin: rue_mohr: actually the compiler is free to assume that your program terminates, so a while(1); may be removed
10:39 AM Emil: wat
10:39 AM Emil: thardin: no
10:39 AM Emil: thardin: with AVRs
10:39 AM rue_mohr: maybe
10:39 AM thardin: depends on the compiler
10:39 AM Emil: the code generated adds a jump to the beginning of main
10:39 AM Emil: that is
10:39 AM Emil: int main(void)
10:39 AM Emil: { things ...}
10:39 AM Emil: but without an infinite loop
10:39 AM Emil: will have a jump to the beginning of main at the end of main
10:40 AM thardin: avr-libc puts that in I think
10:40 AM Emil: yeah
10:40 AM Emil: something like that
10:40 AM Emil: you can stop that behaviour, too
10:40 AM rue_mohr: part of CRT?
10:40 AM Emil: I don't recall the compile time options for it, though
10:40 AM thardin: I think you just add your own _start
10:41 AM Emil: yeah
10:41 AM thardin: the C spec is full of surprises tho
10:42 AM thardin: but possibly grokable, unlike the full C++ spec
10:43 AM Emil: C++ is a monster
10:43 AM Emil: But yeah
10:43 AM Emil: we can't trust the compiler :D
10:43 AM Emil: even when using C
10:45 AM Emil: Also, rue_mohr you might be able to use branches for a more efficient infinite loop
10:45 AM rue_mohr: iirc anything that changes the program counter is 2 cycles
10:45 AM Emil: oh no
10:45 AM Emil: yeah
10:45 AM Emil: noticed
10:46 AM Emil: kind of expected, too
10:46 AM rue_mohr: so adding a snot-load on NOP to your infinite main loop makes your irq timing better
10:46 AM Emil: given it's 16 bits
10:46 AM Emil: rue_mohr: well
10:46 AM rue_mohr: THO, there might be a sleep mode that does it better
10:46 AM Emil: you really might want to fill the remaining space with NOPs :D
10:46 AM Emil: so instead of just 1 nop
10:46 AM Emil: add like 512
10:47 AM rue_mohr: match on a fire
10:47 AM rue_mohr: blue on black
10:47 AM rue_mohr: tears on a river
10:47 AM Emil: sleep might work, too
11:02 AM rue_mohr: great, now I need to know that AND how to make serial usb work
11:02 AM rue_mohr: https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f1/waveshare-open103r/usbserial/usbserial.c
11:02 AM rue_mohr: this might be part of the key
11:30 AM nohitzzz: hi
11:30 AM nohitzzz: im trying out new irc client
11:30 AM nohitzzz: hexchat
11:41 AM Emil: blasphemy
11:45 AM nohitzzz: you use irssi?
11:46 AM kl0wn: i'm using mirc
11:46 AM kl0wn: who's mad
11:49 AM Emil: irssi ofcourse
11:52 AM nohitzzz: i used to use mirc
11:52 AM nohitzzz: then irssi
11:52 AM nohitzzz: then nettalk
11:53 AM nohitzzz: and now hexchat
11:53 AM nuxil: rue_mohr,
11:54 AM nuxil: i edited your code a bit and im trying to compile it. but it errors on me. undefined reference to `NOP'
11:55 AM Emil: nuxil: #define NOP asm("nop")
11:55 AM Emil: iirc
11:56 AM nuxil: when i did.. #include "avrcommon.h" it errored with fatal error: avrcommon.h: No such file or directory
11:56 AM nuxil: but when i changed it to #include <avr/common.h> i got the error i said.
11:56 AM nuxil: Emil, will try that
11:57 AM nuxil: Emil, thanks. that worked.
11:57 AM nuxil: no errors on compile
11:58 AM Emil: nuxil: you can also use _NOP() if you include <avr/cpufunc.h>
12:00 PM nuxil: good to know. :)
12:13 PM polprog: dont think that every code you find or get will work straight away
12:13 PM polprog: instead, look at how it does things
12:13 PM polprog: and adapt it
12:21 PM antto: mirc ftw
12:34 PM Lambda_Aurigae: antto, it crashes on my computer.
12:34 PM Lambda_Aurigae: so I use hexchat instead.
12:34 PM antto: i use hexchat on teh linux
12:35 PM Lambda_Aurigae: same here.
12:35 PM Lambda_Aurigae: I don't use windows.
12:35 PM polprog: hexchat is nice when it comes to gui clients
12:35 PM Lambda_Aurigae: tried mirc on linux...it loads then crashes.
12:36 PM antto: i had to "tweak" hexchat to look as much as possible to my mIRC script: https://i.imgur.com/yd1czwS.png
12:37 PM polprog: nice font
12:37 PM kl0wn: I've used mirc for over half my life, I'll probably never ditch it :|
12:37 PM kl0wn: there is another nice client I wanted to try though, supports mirc scripts, I forget the name though
12:38 PM antto: polprog that's "fixed" 8
12:38 PM kl0wn: https://www.adiirc.com/
12:38 PM polprog: i like Gohu personally
12:38 PM polprog: i usde terminus before
12:38 PM antto: but ya need to enable bitmap fonts because modern linuxes tend to disable them by default >:/
12:38 PM polprog: size 11
12:38 PM antto: if it has to be a vector font - Liberation Mono
12:39 PM antto: but fixed 8 is great for coding
12:39 PM antto: and irc
12:39 PM polprog: i dont know what DPI/resolution you have
12:39 PM polprog: but anything lower than 10 is hard to read for me
12:40 PM antto: both monitors are 17" i think, 1280x1024 both
12:47 PM Lambda_Aurigae: https://tech.slashdot.org/story/17/10/31/0623219/microsoft-engineer-installs-google-chrome-during-presentation-after-edge-freezes?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Slashdot%2Fslashdot+%28Slashdot%29
12:47 PM Lambda_Aurigae: HAHAHAHA!
12:48 PM polprog: whoopsie
12:54 PM antto: why didn't the dumb engineer install firefox?
12:54 PM antto: actually, if all they were doing was accessing something via a web browser, why use win10 ;P~
01:18 PM nohitzzz: there's sale at packtpub.com
01:18 PM Ameisen-: [10:11:48] <Emil> we can't trust the compiler :D
01:19 PM Ameisen-: Mainly because the compilers were designed for 32-bit CPUs :D
01:19 PM Ameisen-: The C++ spec doesn't have more surprises really than the C spec
01:19 PM Ameisen-: the things that are UB are about teh same
01:19 PM polprog: youve grown a dash ? :P
01:19 PM Ameisen-: It's one of the reasons I want to add a new keyword to replace 'volatile' for AVR
01:19 PM Ameisen-: C and C++ mandate that a read of a volatile MUST happen, even if it isn't used
01:20 PM Ameisen-: where, in reality, we want it to mean 'read-through'
01:20 PM Ameisen-: simply meaning do not use what's in cache/registers/whatnot
01:20 PM polprog: so what's your plan on replacing the volatile
01:20 PM Ameisen-: add a keyword like 'readthrough'
01:20 PM Ameisen-: similar to volatile, but no requirement that reads happen if they aren't used
01:20 PM polprog: ok
01:20 PM polprog: makes sense
01:20 PM Ameisen-: let the compiler do its normal magic to determine side-effects
01:21 PM Ameisen-: write should still happen, _unless_ the compiler can determine that that variable is never read
01:21 PM Ameisen-: in which case, the entire variable can be elided
01:21 PM Ameisen-: but that's normal compiler logic
01:21 PM Ameisen-: volatile presently prevents it
01:21 PM Ameisen-: 'volatile' is actually a really bad name on its own given all that it does
01:22 PM polprog: could be worse
01:22 PM polprog: 'variable'
01:22 PM Ameisen-: 'volatile' is a great name for something that is readthrough, but is a terrible name to describe something that must read/write
01:22 PM Ameisen-: volatile basically tells the compiler that read/write of the variable can have side-effects the compiler is unaware of within scope
01:22 PM Ameisen-: but that's too strict of a definition for this
01:22 PM Ameisen-: and isn't meant for what we're doing anyways - it was originally intended for device-mapped memory
01:23 PM Ameisen-: we're basically doing uncached/or so
01:23 PM polprog: mm
01:23 PM Ameisen-: though we don't really have a cache
01:23 PM Ameisen-: there's no good terminology for it
01:23 PM Ameisen-: read-through/write-through is accurate but wordy
01:23 PM polprog: im looking forward to see what you make out of this
01:24 PM Ameisen-: Well, depends how much progress I make on everything
01:24 PM Ameisen-: not touching GCC right now for a few reasons
01:24 PM Ameisen-: most of my work has been towards Clang
01:24 PM Ameisen-: which is easier to implement said things in anyways
01:24 PM polprog: maybe a compiler fork if clang devs turn out to be dicks and reject your work :P
01:24 PM Ameisen-: the Clang devs are easier to work with, I've found
01:24 PM Ameisen-: Clang already has address space support in C++
01:24 PM Ameisen-: the g++ devs have rejected every patch for that
01:25 PM enh: https://www.youtube.com/watch?v=k3lacOYokY0
01:25 PM enh: Hi people
01:25 PM enh: polprog: I adjusted the focus
01:25 PM Ameisen-: also, not sure why the - is there
01:25 PM enh: Moved the laser to the controller pwm and reduced power
01:25 PM Ameisen-: I can't remove it because I'm in channels where I have to be logged in to talk
01:25 PM Ameisen-: but I can't log in because my name is wrong
01:25 PM Ameisen-: :|
01:26 PM Ameisen-: and I'm on a bouncer, so it's not trivial to fix
01:26 PM enh: polprog: Now it is cutting....
01:26 PM polprog: enh: nice
01:26 PM polprog: cool sounds :D
01:26 PM Ameisen- is now known as Ameisen
01:26 PM polprog: also didnt know you can see strong laser beam like that
01:26 PM Ameisen: fixed
01:26 PM polprog: i thought it's only on movies
01:26 PM Ameisen: You see the dust.
01:27 PM polprog: yeah
01:27 PM Ameisen: even weak laser beams can be seen
01:27 PM enh: Still dangerous, but nice!
01:27 PM Ameisen: green is easier
01:27 PM Ameisen: red is hard
01:27 PM Ameisen: blue is easiest
01:27 PM Ameisen: well, green is easiest
01:27 PM Ameisen: blue is strongest
01:27 PM Ameisen: green activates the rods/cones the most in your eye, thus appears brightest
01:27 PM polprog: i like lasers...
01:27 PM * Ameisen does computer graphics
01:27 PM Ameisen: there's a reason the SRGB spec biases towards green the most
01:27 PM polprog: Ameisen: our eyes are most sensitive to green
01:28 PM Ameisen: and that you cannot calculate the luminosity of a color by just using pythagorean theoreem
01:28 PM Ameisen: you have to bias the color first towards gren
01:28 PM Ameisen: green*
01:28 PM Ameisen: and then towards red, least towards blue
01:28 PM Ameisen: don't remember the exact coefficients
01:28 PM polprog: once i had an offer to buy an unknown condition argon laser tube for $20
01:28 PM Ameisen: in fact, there's a debate about the proper coefficients anyways
01:28 PM Ameisen: the SRGB spec ones aren't ideal
01:28 PM polprog: no gamut will be ideal
01:28 PM Ameisen: there's different coefficient sets that work better
01:28 PM Ameisen: no, but there are objectively better ones.
01:28 PM Ameisen: sqrt(r^2+g^2+b^2) is awful
01:29 PM Ameisen: fast, but awful
01:29 PM Ameisen: the SRGB one is OK, but not great
01:29 PM Ameisen: the normal PC SRGB mapping (not spec, most people use a crappy approximation) is color^2.2
01:29 PM Ameisen: which... ain't great
01:29 PM Ameisen: it does a good job of remapping the color range though.
01:30 PM Ameisen: I don't recall what coefficients I use
01:30 PM Ameisen: I'd have to look at my planet renderer demo
01:30 PM Ameisen: which looks awesome, but is also incredibly slow :P
01:31 PM polprog: https://en.wikipedia.org/wiki/Color_space#/media/File:CIE1931xy_gamut_comparison.svg
01:31 PM Ameisen: Yeah, there's no perfect gamut
01:31 PM Ameisen: 'ideal' is the best coefficients that match what you're trying to present
01:31 PM Ameisen: the ones people usually use are never ideal - there's always a better one
01:31 PM Ameisen: not entirely sure how they became so popular
01:31 PM polprog: also, ironic to display that image on a computer screen, wher you cant see the true color
01:31 PM Ameisen: yup
01:32 PM polprog: they became popular because 99% of people dont know what's color gamut
01:32 PM Ameisen: the main trick on LDR PC screens is to remap the colors to a range that can properly be displayed as the designer intends
01:32 PM polprog: and they dont care
01:32 PM Ameisen: and basically 'trick' the eye into seeing what you want it to see
01:32 PM Ameisen: we call it HDR, but it's not
01:32 PM Ameisen: tone mapping and a few other things
01:32 PM Ameisen: though tone mapping is generally done wrong, too
01:32 PM polprog: also, funny how ProPhoto RGB suports a range of cyanish that is outside the range
01:33 PM Ameisen: It has to
01:33 PM Ameisen: to support more of the visible color space, coefficients have to exist outside of it
01:33 PM Ameisen: those are 'dead' areas though, and wasteful when it comes to bandwidth
01:33 PM Ameisen: you don't usually want bit representations that are meaningles
01:37 PM Ameisen: https://imgur.com/a/mnqCW
01:37 PM Ameisen: there we are
01:37 PM Ameisen: had to find the imgur gallry
01:38 PM polprog: nice
01:39 PM Ameisen: those are older pictures, actually
01:39 PM Ameisen: not sure where the newer ones are
01:39 PM Ameisen: :|
01:40 PM Ameisen: I improved city rendering and stuff dramatically
01:40 PM Ameisen: and the overall colors
01:40 PM polprog: ii tried OpenGL once
01:40 PM polprog: made a nice 2d game
01:40 PM Ameisen: that's in Unreal (because I'm lazy), though I've made similar demos using D3D and OpenGL
01:40 PM polprog: gave up when trying to texture 3d stuff
01:40 PM Ameisen: though it's all manual lighting anyways
01:40 PM Ameisen: I just used Unreal as the framework
01:40 PM polprog: i tried unity though
01:41 PM polprog: how hard is unreal?
01:41 PM Ameisen: that depends on your skill level.
01:41 PM Ameisen: I'm an expert rendering engineer with years of experience
01:41 PM Ameisen: so... my comfort level would differ from yours
01:41 PM Ameisen: in fact, I prefer writing things myself to using Unreal
01:41 PM Ameisen: I just wanted to make a quick tech demo
01:41 PM polprog: im a weekend tinkerer with some programming experience
01:41 PM polprog: anyway, not wanting to go back to game design
01:42 PM Ameisen: I preferably would have just used C++ and D3D11/12
01:42 PM polprog: D3D?
01:42 PM Ameisen: yes
01:42 PM Ameisen: OpenGL's only advantage is portability. It is absolutely awful at everything else in comparison.
01:42 PM Ameisen: I used to be big on OpenGL
01:42 PM polprog: ah directx
01:42 PM Ameisen: then I got forced to use D3D when doing console games
01:42 PM Ameisen: and preferred it
01:57 PM Ameisen: but, anyways
01:57 PM Ameisen: I haven't worked on it in a few days (priorities), but still working on clang-av
01:57 PM Ameisen: avr
01:57 PM Ameisen: there's also still some major codegen issues in g++
01:58 PM Ameisen: which... haven't gotten fixed. I've reported htem, there was some analysis, but I don't think that there are _any_ active gcc avr maintainers
01:58 PM twnqx: gcc there are, hot a bug of mine fixed in two days
01:58 PM twnqx: i guess that just noone cares about c++ on an 8bit micro
01:59 PM Ameisen: twnqx - which is a shame
01:59 PM twnqx: your point of view
01:59 PM Ameisen: C++ has a lot of potential to work _better_ on ucpus than C (which I've been trying to prove with my 3d printer firmware)
02:00 PM Ameisen: but with the lack of support, it's hard to get C++ to do the damned stuff in the first place.
02:00 PM Ameisen: lack of support for any language is always a shame, whether you like the language or not
02:00 PM Ameisen: as it discourages people from using the target
02:01 PM twnqx: i don't totally disagree
02:01 PM twnqx: only 90% or so
02:01 PM * Ameisen shrugs
02:01 PM Ameisen: generally, C programmers hate C++
02:01 PM Ameisen: often unusually so, to the point of sabotaging it (not saying you are, but I've seen it)
02:02 PM polprog: im was java programmer "originally" but i like c
02:02 PM polprog: and cpp
02:02 PM Ameisen: I'm sorry for your experience with Java. :(
02:02 PM Ameisen: If you need to talk, I'm here for you.
02:02 PM twnqx: c++ has a great many feature i would like to see in c
02:02 PM polprog: i was 10 and i bought a java book on programming
02:02 PM polprog: and i learnt from the book
02:02 PM polprog: that's all
02:02 PM polprog: ;)
02:02 PM Ameisen: C++'s problem is it tries to stay backwards compatible, but it sort of makes it harder to use since it makes the syntax more and more ackward.
02:03 PM Ameisen: it already is no longer a superset of C, yet there's an insistence on maintaining compatibility
02:03 PM Ameisen: so now there's 10 ways to do everything
02:03 PM Ameisen: 8 of them are discouraged
02:03 PM polprog: p much
02:04 PM Ameisen: I still like C++, but you have to control how you use it
02:04 PM Ameisen: But that's not terribly different in any language.
02:04 PM polprog: you can write aboimnations in any language
02:04 PM polprog: abominations*
02:04 PM Ameisen: some languages you can _only_ write abominations
02:04 PM Ameisen: like brainfsck
02:04 PM polprog: or emacs lisp
02:05 PM polprog: i tried
02:05 PM polprog: all i can do is add a simple line to my init file
02:05 PM polprog: :D
02:06 PM twnqx: the things i extremely dislike is a) the cout syntax (imho FAR less readable than printf), b) the waste, both in performance and in memory, through vtable lookups, and c) the use of dynamic memory and resulting fragmentations
02:06 PM polprog: cout is cancer
02:06 PM twnqx: only valid for µC, though i generally feel like evrything less than 100% runtime efficiency is bad
02:07 PM polprog: creating a whole bloody object (ostream) to print a string or so
02:07 PM twnqx: templates, custom types/operators, namespaces, etc are great
02:07 PM polprog: yea
02:07 PM twnqx: not sure about the new features like lambdas, haven't used them yet
02:08 PM antto: i use C++ on teh xmegas
02:08 PM antto: in C, i really miss encapsulation
02:08 PM antto: classes/structs with methods
02:09 PM polprog: i liked encapsulation in java
02:09 PM twnqx: while i agree to that, indirect jumps are slow on µCs, extra cycles for memory access
02:09 PM polprog: that you can have static methods... all sorta jazz
02:09 PM twnqx: no caches, no runtime optimization like java, etc
02:10 PM antto: now i tried using template metaprogramming, starting off with rewriting my buffered interrupt-driven USART on the atmega2561
02:10 PM twnqx: just wasted cycles doing nothing
02:10 PM antto: so far it works
02:10 PM polprog: i think i wrote a buffered interrupt driven uasrt
02:10 PM polprog: or half of it
02:10 PM twnqx: i have the problem that the C wrappers around interrupt routine are FAR too slow
02:10 PM twnqx: saving all registers is soooooo damn slow
02:10 PM polprog: i use buffer for input and printf for output
02:11 PM polprog: twnqx: you can always make a naked isr and write it in asm
02:11 PM polprog: if you need super speed
02:11 PM antto: polprog mine does interrupt driven in both receive and transmit
02:11 PM twnqx: that's what i had to resort to, yes
02:11 PM twnqx: i only have ~16 cycles for the whole time
02:13 PM antto: i gotta try to make an object which does ATOMIC_BLOCK() in its constructor and then gets out in its destructor
02:13 PM antto: ;P~
02:14 PM polprog: lol
02:14 PM polprog: can you strech an atomic block like that in between methods
02:14 PM polprog: or would you have to use sei() and cli()
02:14 PM antto: well, not the macro itself
02:16 PM antto: oh sh*t, hide all the "plusplus" !! Lambda_Aurigae is here
02:16 PM * antto whistles innocently
02:17 PM * polprog hides the C++ under a pile of assembly listings
02:17 PM * antto calls all destructors and clears the RAM
02:18 PM polprog: s/++/+=1/
02:18 PM polprog: done
02:22 PM Ameisen: twnqx - so
02:23 PM Ameisen: what do you recommend to do for inheritance in the case of 'b'?
02:23 PM Ameisen: every implementation of inheritance I've seen in C has literally implemented vtables by hand anyways
02:23 PM twnqx: "don't", on µC
02:23 PM Ameisen: Ok, then don't use inheritance in C++ on uC?
02:23 PM Ameisen: problem solved?
02:23 PM Ameisen: vtables are only generated if virtual functions exist.
02:23 PM Ameisen: So... don't use them.
02:23 PM twnqx: indeed
02:24 PM twnqx: also make all your classes static
02:24 PM Ameisen: Not really a problem with C++.
02:24 PM twnqx: indeed
02:24 PM Ameisen: Rather using a language tool that isn't appropriate for the situation.
02:24 PM Ameisen: c) is similar
02:24 PM twnqx: just you strip it basically down to C
02:24 PM Ameisen: You still have templates/classes in general/constexp
02:24 PM Ameisen: constexpr
02:24 PM twnqx: yes
02:24 PM Ameisen: templates haven't caused bloat since, what, 2010?
02:24 PM Ameisen: ICF works well when you let it.
02:24 PM Ameisen: most people don't let it though, which is frustrating
02:25 PM Ameisen: I see people explicitly turning off code-folding a lot
02:25 PM Ameisen: then they complain their binaries are larger. You don't say!
02:25 PM twnqx: -funroll-all-loops !
02:25 PM Ameisen: D:
02:25 PM Emil: -funroll :D
02:25 PM Ameisen: I actually have fun with constexpr in AVR
02:26 PM Ameisen: generating code depending on datasets, so optimal types and algorithms are used without my intervention everywhere.
02:26 PM twnqx: my biggest complaint about avr gcc that i found so far was a code generation issue where the compiler would generate a 16bit intermediate with 8 bit input and output variables
02:26 PM Ameisen: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82658
02:26 PM twnqx: emitting an unneccessary instruction
02:26 PM Ameisen: I reported that already
02:26 PM Ameisen: it doesn't emit just one instruction in all cases.
02:26 PM Ameisen: uint8_t >> 3 emits, I think, 9?
02:27 PM Ameisen: it generates a 32-bit intermediate in C++
02:27 PM Ameisen: might be a slightly different bug though
02:28 PM twnqx: ldi r25,0
02:28 PM twnqx: asr r25
02:28 PM * twnqx blinks
02:28 PM Ameisen: yup
02:28 PM Ameisen: thus why I reported it
02:28 PM Ameisen: it appears to be a g++ frontend issue
02:28 PM Ameisen: as it also causes x86-64 to generate different code
02:28 PM Ameisen: Clang doesn't do that, btw
02:29 PM Ameisen: it just does other incredibly stupid things because I haven't finished writing all of the reduction code
02:29 PM Ameisen: Clang doesn't have separate frontends in the way gcc does, which makes bugs like that more rare
02:29 PM Ameisen: they're far more integrated
02:29 PM twnqx: did you test what happens if you do local = val >> 1; ?
02:29 PM Ameisen: yes.
02:29 PM Ameisen: That's actually what the gcc and g++ frontends convert it to anyways.
02:29 PM twnqx: ah
02:30 PM twnqx: not quite though, they do val >>= 1; :P
02:30 PM Ameisen: the difference is the gcc frontend doesn't promote 'val' to 'int', whereas g++ does (to match '1')
02:30 PM twnqx: and eliminate local completely (or to a register)
02:30 PM Ameisen: look at Richard's comment
02:30 PM Ameisen: that's the output from the middle end
02:30 PM Ameisen: oh, eliminate local
02:30 PM Ameisen: I haven't tried that
02:31 PM twnqx: well... i do *think* that the widening was the bug that i got fixed a few years ago
02:31 PM Ameisen: same result
02:31 PM twnqx: did you try >>= (unsigned char) 1; ?
02:32 PM twnqx: if so, it would be similar to my bug :P
02:32 PM Ameisen: same result
02:32 PM twnqx: ok, then it's different, there is no excuse left to turn this into an int in between
02:32 PM Ameisen: it still tries widening as the c++ frontend, for whatever reason, tries always to operate on int
02:32 PM twnqx: that's bad for an 8bit :(
02:32 PM Ameisen: yup
02:32 PM Ameisen: thus why I reported it
02:32 PM Ameisen: also why I'm working on Clang
02:32 PM Ameisen: Clang doesn't have issues like that
02:32 PM Ameisen: just other issues
02:33 PM twnqx: i guess the gcc family has just grown for too long
02:33 PM antto: choose your issues today!
02:33 PM twnqx: i have a compiler for tricore
02:33 PM twnqx: which is some gcc 3.8-ish
02:33 PM Ameisen: the main issue is that gcc's frontends are completely separate for the most part
02:33 PM twnqx: it breaks if you compile it to a 64bit binary, and you can't even compile it with a gcc 4
02:33 PM Ameisen: whereas clang basically treats them like extensions
02:33 PM Ameisen: you hit mostly the _same_ code in Clang, and almost entirely different code in GCC
02:34 PM Ameisen: so you usually won't see a codegen bug like this with only one frontend
02:35 PM Ameisen: I tested the issue on other architectures to raise awareness, mainly
02:35 PM Ameisen: but the only one that even showed a change was x86-64, and the change doesn't change performance
02:35 PM Ameisen: AVR just has that nice mix of horrible traits that cause it to express badly
02:47 PM Emil: eh?
02:47 PM Emil: AVR is suuuper simple
02:47 PM Emil: what horrible traits does it have?
02:49 PM Ameisen: that it's super simple.
02:49 PM Ameisen: Compilers don't like that.
02:49 PM Ameisen: They like architectures that _at least_ have instructions that map 1:1 with their intermediate language.
02:49 PM Ameisen: AVR requires a lot more support to map to the IL
02:50 PM Ameisen: and often, you cannot support it optimally due to assumptions made in the middle-end
02:50 PM twnqx: "int fits into one register"?
02:51 PM Ameisen: that's usually an assumption that compilers make :P
02:51 PM polprog: im all against using ambigous types
02:51 PM polprog: always uint8_t etc
02:51 PM Ameisen: particularly since int being 2-bytes is a violation of the spec anyways
02:51 PM Ameisen: as it's not the actual word-size of AVR
02:51 PM Ameisen: the other issues are how pointers in AVR work, and how shifts work
02:51 PM polprog: what;s the word size in avr? 8 bits?
02:52 PM Ameisen: yeah
02:52 PM twnqx: yes
02:52 PM Ameisen: so the compiler, off the bat, is presuming that 16-bits is optimal
02:52 PM Ameisen: when it's not
02:52 PM Ameisen: then it has to do fancy things to set up pointers that don't make sense in the IL, then it has to do fancy things for shifts...
02:52 PM Ameisen: generally, the compiler presumes shifts are cheap
02:52 PM Ameisen: not in AVR, though
02:53 PM polprog: how are shifts done on non avr?
02:53 PM Ameisen: compilers like simple archs, but not too simple
02:53 PM Ameisen: AVR is on the far side of the other side
02:53 PM polprog: ALU can shift n bytes at once?
02:53 PM Ameisen: they have actual shift instructions, variable and immediate
02:53 PM Ameisen: not just shift right 1, and shift left 1 (which is really add rd, rd)
02:53 PM Ameisen: and arithmetic shift
02:54 PM twnqx: well, you need arithmetic shift to shift more than one register long values
02:54 PM Ameisen: yup
02:54 PM Ameisen: but in general, shifts on, say, x86 or arm are incredibly cheap
02:54 PM Ameisen: and that's usually what the compiler presumes as well
02:54 PM Ameisen: and the shift sequences have to be manually written in the compiler
02:54 PM Ameisen: gcc has those reductions implemented, I'm adding them in Clang
02:55 PM Ameisen: the IL only goes down to the shift level. It doesn't go lower, so you have to lower it further.
02:55 PM polprog: heh, write a better arch virtual machine ;) and compile for that machine?
02:55 PM Ameisen: This also tends to impede some optimizations.
02:55 PM Ameisen: Since optimizations generally happen at the IL level
02:55 PM Ameisen: well, you'd have to fundamentally change things
02:56 PM Ameisen: THe proper way to get an AVR compiler that's great is to write a compiler for AVR.
02:56 PM Ameisen: as it's fundamentally different from more sophisticated architectures
02:56 PM Ameisen: you'll always be handicapped otherwise
02:56 PM polprog: wonder how pics present in comparison
02:57 PM Ameisen: those more sophisticated archs are also what GCC focuses development on :)
02:57 PM polprog: i wanna try some older stuff
02:57 PM twnqx: 6502? :D
02:57 PM polprog: like 8051 or z80
02:57 PM Ameisen: I mean
02:57 PM polprog: maybe 6502 too ;)
02:58 PM Ameisen: you could _probably_ make a new AVR compiler... rip LLVM's frontends
02:58 PM Ameisen: and don't use their middle end
02:58 PM twnqx: get a commodore 128, you have both z80 and 6502!
02:58 PM Ameisen: would take work though
02:58 PM polprog: i could write an avr RAM emulator for z80 or 6502, or any low speed cpu
02:58 PM Ameisen: z80 is more complex than AVR too
02:58 PM Ameisen: :D
02:58 PM Ameisen: z80 is a more complex 8080
02:58 PM Ameisen: which is x86
02:58 PM polprog: i have a book on z80, in theory if i had the hardware i could dive in
02:58 PM Ameisen: well, pre-x86, but same line
03:43 PM Lambda_Aurigae: antto, I wasn't here at the time. I was out breaking copiers. And, you can have all your plusplus. I won't take it!
03:56 PM polprog: oh my god
03:56 PM polprog: remember i once bought a grab bag of old shit like diodes, transistors etc
03:56 PM polprog: there were some chips on a styrofoam piece
03:56 PM Emil: yeees
03:56 PM polprog: one of them is....
03:56 PM polprog: UCY7880
03:57 PM polprog: polish clone of 8080 by CEMI
03:57 PM Emil: https://pl.wikipedia.org/wiki/MCY7880
03:57 PM Emil: It was the only microprocessor manufactured in the 1980s in Poland. Its retail price was 2650 gold in 1986
03:57 PM Emil: wtf :D
03:57 PM polprog: maybe i could make it run
03:57 PM polprog: 2650 "gold" :P
03:57 PM Emil: "2650 gold"
03:57 PM Emil: what is this
03:57 PM Emil: Is Poland in an RPG world?
03:58 PM Emil: oops
03:58 PM polprog: zloty is both the name of the currency and the adjective for gold :P
03:58 PM Emil: It was autotranslated for me :D
03:58 PM Emil: polprog: not bad :D
03:58 PM nuxil: so.. im kind of lost in the woods here. i am able to control the dutycycle of a pwm using a pot meter. now. how would i go about making the freq adjusteble too ? so i got 2 pots. 1 for freq and one for duty cycle. ?
03:59 PM polprog: nuxil: read the adc value, process it, write to pwm control registers
03:59 PM Emil: nuxil: you can make both the freq and the dutucycle adjustable but it requires some software control
03:59 PM polprog: every program works like that: input > process > output
03:59 PM Emil: you can make it work nicely with TIMER1
03:59 PM Emil: nuxil: what are you trying to control or do?
04:00 PM Emil: why do you need both the freq and the dutycycle?
04:00 PM nuxil: Emil, im trying to make a squar wave func generator with adjustble duty cycle using a atiny85.
04:00 PM polprog: Ok, now i need some 8080 guru to tell me how to revive this poppy
04:00 PM polprog: and i need to take a trip to the place i got the bag and get a spare
04:01 PM Lambda_Aurigae: polprog, you need memory first..parallel eprom or flash, and sram.
04:01 PM Emil: nuxil: just dutcycle?
04:01 PM Emil: nuxil: or freq also?
04:01 PM nuxil: i need to be able to adjust both
04:01 PM nuxil: well want to.
04:01 PM polprog: there's this recording of a popular science show of the times showing the production of the cpu: https://www.youtube.com/watch?v=AJGp7keIA_o
04:03 PM Emil: nuxil: okay so
04:03 PM Emil: nuxil: you need to select a timer mode where you can control the TOP
04:03 PM Emil: https://emil.fi/jako/kuvat/2017-10-31_22-32-11_pBDYjk95.png
04:04 PM Emil: for square wave generation if you don't care about phase
04:04 PM Emil: fast pwm might be the bets?
04:04 PM nohitzzz: Lambda_Aurigae, my sample AT89C51RC2 has been shipped
04:04 PM nuxil: Emil, i dont care about phase
04:05 PM Emil: nuxil: then FAST PWM
04:05 PM Emil: nuxil: then you adjust OCR0A for frequency
04:05 PM Emil: meaning you can't use COMA as output
04:05 PM Lambda_Aurigae: nohitzzz, kewl.
04:05 PM Emil: you need to use COM0B
04:06 PM Emil: Clear OC0A/OC0B on Compare Match, set OC0A/OC0B at BOTTOM
04:06 PM Emil: (non-inverting mode)
04:06 PM Emil: Select that one
04:06 PM Emil: and then change OCR0B to select duty cycle
04:06 PM Emil: Now you have an issue if OCR0A<OCR0B
04:07 PM polprog: rightmost: https://puu.sh/ybLrA/74185fea6d.jpg
04:07 PM Emil: so every time you update OCR0A you should also update OCR0B
04:07 PM polprog: i should power it up and provide some clock signal to see if anything happens.
04:07 PM polprog: fortunately got a datasheet
04:07 PM Emil: If you've got the datashit you're golden
04:08 PM Emil: polprog: 2:50 onwards
04:08 PM nuxil: i will try make sense of what you said. would be nice with a quick dirty example :p
04:08 PM Emil: seeeeexyyy
04:08 PM Emil: Light pens
04:08 PM polprog: shame no subtitles
04:09 PM polprog: but that tv program was ahead of it's times
04:09 PM Emil: Seeeexyyy
04:09 PM polprog: the guys explained those kind of topics to average person
04:09 PM polprog: hence the cooking metaphor
04:09 PM polprog: unfortunately one of them died in a car crash.
04:10 PM polprog: that was the end of Sonda. the best TV programme in poland
04:10 PM Emil: polprog: how old are you exactly
04:10 PM polprog: 17
04:10 PM Emil: I have this doubt about that :D
04:10 PM Lambda_Aurigae: polprog, most 8080 chips don't have any memory at all.
04:11 PM polprog: it's a bare cpu
04:11 PM Emil: which means
04:11 PM Emil: you
04:11 PM Emil: can
04:11 PM Emil: bit
04:11 PM Emil: bang
04:11 PM polprog: gonna need this an that
04:11 PM Emil: it
04:11 PM Emil: with buttons :D
04:11 PM polprog: maybe i will have to :D
04:11 PM Lambda_Aurigae: usually there was an external memory interface chip as I recall.
04:11 PM polprog: i will find it in the datasheet i suppose
04:11 PM polprog: shame it's in polish, i would show you
04:11 PM Lambda_Aurigae: there are plenty of 8080 builds out there.
04:14 PM Emil: nuxil: open the attiny85 datasheet
04:14 PM Emil: http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf
04:14 PM Emil: To section 8-bit timer/counter0
04:14 PM Emil: (or 1 if you want to use that one)
04:14 PM Emil: and read that section through
04:14 PM polprog: apparently resetting doesnt zero the accumulator, SP, general purpose registers
04:15 PM Emil: especially the register descriptions
04:15 PM Emil: nuxil: the good thing is that what you are after is "quite easily achievable"
04:15 PM Emil: but the good thing for you is that you have to read the datasheet, I'm not going to code it for you ;)
04:15 PM polprog: it has dma
04:15 PM Emil: Unless you pay me
04:15 PM Emil: polprog: <3
04:15 PM polprog: lol
04:16 PM Emil: paypal.me/emilfihlman should work ;D
04:16 PM Emil: Or a direct transfer to FI06 5246 0620 0156 54 with BIC OKOYFIHH
04:18 PM polprog: i can send you 1 gold
04:19 PM Lambda_Aurigae: 1 gold what?
04:19 PM Emil: <3
04:19 PM Emil: polprog: I'll humbly accept
04:19 PM polprog: emil just laughed at translation of zloty = gold (polish currency)
04:19 PM Emil: Lambda_Aurigae: look above
04:19 PM polprog: because it literally means gold
04:19 PM Emil: 2017-10-31 22:25:51 +0200
04:20 PM Emil: from that a bit further down
04:20 PM Emil: the wiki link
04:20 PM Lambda_Aurigae: Emil, I saw that..
04:20 PM Emil: polprog: from now on you must carry with you a sack of gold coins
04:20 PM polprog: :P
04:21 PM Lambda_Aurigae: 1 zloty is apparently worth 0.27 US Dollar currently.
04:24 PM Emil: That's some cheap ass gold
04:25 PM polprog: warcraft gold is still cheaper
04:26 PM Ameisen: the tinys are annoying because some of them don't have the word-size instructions
04:26 PM Ameisen: more for the copmiler to handle.
04:26 PM Ameisen: :|
04:27 PM polprog: hmm, needs some power supply handling
04:27 PM Lambda_Aurigae: Ameisen, wait till microchip comes out with the next generation of pic/avr hybrids....it'll get even worse.
04:27 PM polprog: proper order of bringing up
04:27 PM Lambda_Aurigae: polprog, that thing also needs clock source magic as I recall.
04:27 PM polprog: yeah, i saw the waveforms in the datasheet
04:28 PM polprog: i think ill stay with avr assembly for now
04:28 PM Ameisen: Lambda_Aurigae - it will just be 6 instructions
04:28 PM Ameisen: :|
04:29 PM Lambda_Aurigae: maybe they will do a mindfuck processor.
04:30 PM polprog: Lambda_Aurigae: maybe in VHDL
04:30 PM Lambda_Aurigae: polprog, that's been done already.
04:30 PM polprog: somebody once mentioned somewhere an idea for a program that takes VHDL and spits out a PCB full of 7400 nands
04:30 PM Lambda_Aurigae: I want it in hard sillycon!
04:30 PM polprog: ^^
04:31 PM Lambda_Aurigae: think I saw that on hackaday a few years back.
04:31 PM polprog: VHDL->7400 ?
04:31 PM Lambda_Aurigae: yeah.
04:31 PM Lambda_Aurigae: maybe it was all planning stages but I remember it mentioned.
04:34 PM polprog: the odd clock stuff and supply puts me off
04:34 PM polprog: maybe later
04:34 PM polprog: maybe z80
04:35 PM Ameisen: https://github.com/ameisen/avr-llvm
04:35 PM Ameisen: https://github.com/ameisen/avr-clang
04:35 PM Ameisen: if anyone wants to contribute
04:35 PM polprog: z80 looks like it takes a single +5 supply
04:36 PM polprog: Ameisen: got any to do list apart from the shift table>
04:36 PM Ameisen: not off hand
04:36 PM Ameisen: mainly just comparing things to what GCC does
04:36 PM Ameisen: and trying to bring them in-sync
04:36 PM polprog: the shift table is still in the works?
04:39 PM Ameisen: yeah
04:39 PM Ameisen: it's a large task in that there's a lot to put in
04:39 PM Ameisen: (64+48+32+24+16+8) * 5 * 6 operations
04:40 PM Ameisen: 5760
04:40 PM Ameisen: A number can probably be duplicated to a degree
04:40 PM Ameisen: which will simplify things
04:40 PM Ameisen: might be possible to automate some of the lowering as well]
04:40 PM Ameisen: Heh, should write a brute-forcer which will try a ton of instruction sequences to see which one works
04:52 PM akk: Can anyone recommend a good tutorial on attiny programming with avr-gcc?
04:53 PM akk: I just got an attiny85, and got a blink example working (yay) but now I want to understand it better
04:53 PM akk: things like DDRB and PORTB, what ports are available and so forth.
04:54 PM polprog: akk: datasheet lists all ports, peripherals etc
04:54 PM polprog: with code examples
04:54 PM akk: Okay, I'll look there, if that's the best place to start.
05:02 PM akk: polprog: Yes, it's making more sense now, thanks.
05:16 PM Lambda_Aurigae: akk, read the datasheet...cover to cover...twice...then use google to search.
05:18 PM akk: In particular I'm trying to figure out why some tutorials write 0x8 to PINB, while some write 0xff, when the datasheet says all that's needed is to write logic 1.
05:18 PM akk: But I'm only up to pave 60 of the datasheet, maybe there's something later that will tell me that 0x8 is a logic 1 but 0x1 isn't.
05:19 PM twnqx: because it's per bit
05:19 PM polprog: PINB is whole 8 bits
05:19 PM twnqx: 0x01 - pin 0 of the bus, 0x02 - pin 1 of the bus, ... , 0x80 - pin 7 of the bus
05:20 PM Lambda_Aurigae: akk, well,,,you have 8 pins...0x08 sets a single one....0xFF sets all 8.
05:20 PM Lambda_Aurigae: it's called math.
05:21 PM akk: I haven't gotten to the part in the datasheet where it explains which bits correspond to which pins on the chip. I'll keep reading.
05:21 PM twnqx: bit 0 to 0, bit 7 to 7 :P
05:21 PM twnqx: and i am pretty sure it's right there
05:21 PM Lambda_Aurigae: section on i/o ports.
05:21 PM Lambda_Aurigae: many bits in many registers do many things.
05:24 PM NoHitWonder: polprog https://www.youtube.com/watch?v=bAdqazixuRY
05:25 PM polprog: that rigol in 0:20 :P
05:26 PM Lambda_Aurigae: FAKE!
05:26 PM Lambda_Aurigae: no way that laser is that powerful.
05:26 PM polprog: you dont say
05:27 PM polprog: cool
05:27 PM Lambda_Aurigae: the noise is horrid too.
05:27 PM Lambda_Aurigae: probably supposed to be music I suppose.
05:28 PM polprog: na vkus i cvet tovarishchi nyet
05:29 PM Lambda_Aurigae: if you say so.
05:29 PM Lambda_Aurigae: I don't do russian.
05:30 PM Lambda_Aurigae: unless she is really cute.
05:30 PM polprog: ther are no friends for taste and color
05:31 PM Lambda_Aurigae: no accounting for taste
05:32 PM polprog: yeah
05:32 PM Lambda_Aurigae: I'm partially tone deaf...plus I don't care for that kind of music.
05:32 PM polprog: it's a very simple track, they probably focused more on the robot cgi
05:32 PM Lambda_Aurigae: and never did understand music videos.
05:33 PM polprog: me neither
05:43 PM NoHitWonder: those are real robots playing tho. mixed with some cgi
05:43 PM NoHitWonder: https://nigelstanford.com/Automatica/behind_the_scenes
05:45 PM polprog: "some"
05:46 PM polprog: :D
05:55 PM Emil: twnqx: not bus
05:55 PM Emil: twnqx: register
06:00 PM Emil: polprog:
06:00 PM Emil: if those kind of lasers existed
06:00 PM Emil: hoooot daamn
06:00 PM Emil: we would have starwars
06:02 PM Emil: A laser that powerful and coherent and clean
06:02 PM Emil: it's like
06:02 PM Emil: one of those scifi ones where with enough energy and correct wavelength you can have the beam collapse onto itself, basically making a self focusing optic
06:03 PM Lambda_Aurigae: then people could burn down other people without the sound of a gun!
06:03 PM Emil: And once it's focused
06:03 PM Emil: it doesn't really widen
06:03 PM Emil: over distance
06:04 PM Emil: That kind of power could instantly kill a human from multiple kilometres away
06:04 PM polprog: whatever, just dont cross the beams
06:04 PM Lambda_Aurigae: polprog, that's a proton pack, not a photon device.
06:04 PM Emil: https://en.wikipedia.org/wiki/Self-focusing
06:04 PM Emil: It's not even fully scifi :D
06:05 PM Lambda_Aurigae: man portable proton accelerator.
06:05 PM Emil: Self focusing laser beams
06:05 PM Lambda_Aurigae: yup.
06:06 PM Lambda_Aurigae: unfortunately as you get more powerful, the material tends to vaporize rather than do the focus thing.
06:06 PM Emil: For air, the critical power is 2.4GW
06:07 PM polprog: school science fair some time ago: https://puu.sh/ybQl0/469afe1895.jpg
06:07 PM Lambda_Aurigae: that's almost twice what you need for time travel!
06:07 PM Emil: That's infrared laser
06:07 PM Emil: it would instantly umm
06:07 PM Emil: I'm not sure what if would actually
06:07 PM Emil: wait
06:07 PM Emil: yes
06:07 PM polprog: i would post my face but my haircut looks terribly on the only pic i have
06:07 PM polprog: from there
06:07 PM Emil: it would instantly deliver so much energy to air that it would turn to plasma
06:07 PM Emil: and subsequently ionise
06:07 PM polprog: night
06:07 PM Emil: Good night
06:23 PM akk: Just verifying: there is no PORTA on an attiny85, and all I/O is on PORTB, right? I don't see PORTA mentioned in the datasheet, just PORTB.
06:35 PM Tom_L: likely story
06:38 PM Lambda_Aurigae: akk, pretty much.
06:38 PM Lambda_Aurigae: starting with an attiny is kinda hard too...you are very limited on ram.
06:38 PM Lambda_Aurigae: so, if you are programming in C, you have a very very limited stack.
06:39 PM Lambda_Aurigae: your variables fill the ram rather fast, so, you gotta be very careful.
06:39 PM thardin: C on a tiny feels foolish
06:39 PM Lambda_Aurigae: it's doable.
06:39 PM Lambda_Aurigae: just limited.
06:40 PM Lambda_Aurigae: tiny85 does have 512 bytes of ram as I recall.
06:40 PM Lambda_Aurigae: about half of what my second computer had when I first got it....it had 1K of ram and a z80 processor.
06:44 PM LeoNerd: I do C on a tiny85 all the time
06:45 PM Emil: thardin: bullshit
06:45 PM Emil: Lambda_Aurigae: wtf mate
06:45 PM Emil: C on tiny85 is just fine
06:45 PM Emil: if you don't program shit
06:45 PM Emil: program well and everything is fine
06:45 PM Emil: duh
06:45 PM Lambda_Aurigae: well, yeah.
06:46 PM Lambda_Aurigae: but, how many people who come from windows programming know how to write anything like tight code?
06:46 PM Emil: Not my problem
06:46 PM Emil: ;)
06:46 PM Lambda_Aurigae: now, C on a tiny13 would be,,,,fun.
06:46 PM Emil: well
06:46 PM Emil: that's something else :D
06:46 PM thardin: 512B is positively decadent
06:46 PM Emil: what was the ram on 13?
06:46 PM Emil: 128 bytes?
06:47 PM Lambda_Aurigae: that much?
06:47 PM Emil: no
06:47 PM Emil: 64
06:47 PM Emil: 1k of memory, too :D
06:47 PM Lambda_Aurigae: 32 general purpose registers and 64 bytes of ram.
06:47 PM Emil: meaning 512 instructions
06:48 PM Lambda_Aurigae: that's like, one pin toggle for arduino libs!
06:48 PM Emil: that's actually almost true :D
06:48 PM Lambda_Aurigae: I know!
06:50 PM Lambda_Aurigae: man but did these bacon-cheese-burgers turn out good.
06:50 PM Lambda_Aurigae: 2 pounds of burger, 1 pound of ground up bacon, 8 ounces of shredded sharp cheddar...mix, patty, grill..
07:07 PM enh: hi
07:08 PM NoHitWonder: hi
07:10 PM Emil: Good night
07:12 PM NoHitWonder: nite
08:34 PM Ameisen: Lambda_Aurigae - I do
08:34 PM Ameisen: but I went into game development, and rendering engine development
08:34 PM Ameisen: normal C++ doesn't suffice there
08:40 PM NoHitWonder: what is your day job, if i may ask?
08:40 PM NoHitWonder: do you still work in game dev?
08:43 PM Ameisen: not anymore
08:43 PM Ameisen: hours sucked
08:58 PM enh: Just discovered that the CNC controller PWM outputs 3.3V, while the laser driver expects 5V.
09:07 PM theBear: i quit my day job, now i just do irc-standup.. you know, bad one-liners, disappointingly unintelligent wordplay, maybe even a pun or two to fill in the gaps <wink>
09:13 PM enh: How should we send you money, theBear?
09:19 PM theBear: erm, asap, but in rationed portions, for the safety of myself and others <grin>
09:25 PM enh: A pity. I was thinking of sending you a miliion USD just now. I'll send a cent per year, then.
09:42 PM Ameisen: NoHitWonder - however, I'm one of the relatively few C++ programmers who knows low-end development fairly well
09:42 PM Ameisen: To me, it's a shame, as it means there's very few C++ programs for true-low end that actually take advantage of the language
09:42 PM Ameisen: the ones I see are hardly C++
09:56 PM enh: M0
10:02 PM Ameisen: Any of you guys have a floating point library that handles things like float16/24, or unsigned float?
10:20 PM tpw_rules: who would have such a thing
11:38 PM Casper: Ameisen: a short float could be usefull, but I don't think there is one, but a 24 bits one? never hear of that... Not to say they don't exists...
11:39 PM Casper: but chance is that the 1 bytes saved in ram would add so much code complexity that it may not be worth it