#avr Logs

Aug 22 2017

#avr Calendar

01:00 AM lemm|ngs is now known as lemmings
01:09 AM lemmings is now known as lemming5
01:12 AM lemming5 is now known as lemmings
01:15 AM Guest23877 is now known as `z
01:18 AM rue_shop3: anyone wanna be abused?
01:18 AM * rue_shop3 waits for a printer to explode
01:18 AM rue_shop3: is anyone even awake?
01:18 AM rue_shop3: aha, there, it exploded, sweet
01:25 AM rue_shop3: Chillum, vancouver?
01:26 AM Chillum: Victoria
01:26 AM rue_shop3: huh
01:26 AM rue_shop3: school?
01:26 AM Chillum: too cool for school
01:26 AM rue_shop3: hmm
01:26 AM rue_shop3: what are you doing with avrs?
01:27 AM Chillum: currently, beer fermentation box
01:27 AM rue_shop3: with solinoids?
01:28 AM rue_shop3: and lights?
01:28 AM rue_shop3: and buzzers?
01:28 AM rue_shop3: and keypads?
01:28 AM rue_shop3: does it have wireless?
01:34 AM rue_shop3: hah, I seem to be good at guessing my new credit card number!
01:35 AM Haohmaru: rue_prophet
01:35 AM rue_shop3: ok I got two ethernet modules, see if I can put one on my cnc later
01:36 AM rue_shop3: it would be nice to stream the nc to it over the network instead of the looooooong usb cable
01:36 AM * rue_shop3 looks at the trampled usb cable going across the shop floor
01:37 AM rue_shop3: I suppose that should be a tcp connection
01:37 AM rue_shop3: udp could be a bad thing for that
01:40 AM rue_shop3: ok, last I left off with the servo controller, I wored out that I should have working code, but have no way to test it..
01:43 AM Haohmaru: rue_shop3 udp packets can get lost and also arrive out of order and that's considered "fine"
01:45 AM rue_shop3: yea
01:45 AM rue_shop3: thats why spooling NC over udp would be bad
01:46 AM rue_shop3: have you ever used a enc28J60 with an avr?
01:47 AM rue_shop3: I wonder if its possable to pull relivent code from the esp8266 project
01:48 AM Haohmaru: rue_shop3 i was looking into it, but went another direction
01:48 AM Haohmaru: the enc28 stuff is just bare ethernet MAC or so
01:48 AM Haohmaru: i use w5500 which has tcp/udp sockets
01:50 AM rue_shop3: hmm, costs about twice, but, hey, what the hell, $4usd off the wallet
01:52 AM Haohmaru: the w5500 is nice, you have to configure it, it doesn't have a MAC address, and then you can open up to 8 tcp client sockets, or one listen socket, etc..
01:52 AM Haohmaru: it has configurable data buffers
01:52 AM rue_shop3: I only need one
01:52 AM rue_shop3: ... so, what port is serial usually done over?
01:52 AM rue_shop3: :)
01:53 AM Haohmaru: you can get it in a breadboard friendly module wiz550io
01:53 AM Haohmaru: rue_shop3 what do you mean?
01:54 AM rue_shop3: nothing
01:54 AM rue_shop3: "Wiznet Ethernet shield"
01:54 AM rue_shop3: yea, 5500 based
01:54 AM rue_shop3: ok
01:54 AM rue_shop3: byte mac[] = {
01:54 AM rue_shop3: 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
01:54 AM Haohmaru: that chip is SPI btw, you need to tickle it
01:54 AM rue_shop3: that would explain the first code line
01:55 AM rue_shop3: tahnks
01:56 AM rue_shop3: if nothing else, I have more junk for my goodies box
01:56 AM rue_shop3: :)
05:24 AM Emil: Hmm
05:24 AM Emil: How could I do spi write if I don't care about return information
05:24 AM polprog: just write and then dont read the data register
05:25 AM Emil: And only stop if a transfer is in progress when trying to write moar data
05:25 AM polprog: that's how i implemented a read only spi on the maxim thermometer
05:25 AM Emil: polprog: problem is
05:25 AM polprog: oh wait
05:25 AM Emil: yeah
05:25 AM polprog: you need write only
05:25 AM Emil: yup
05:25 AM polprog: but that's the same thing, just write twice
05:25 AM LeoNerd: just ignore reply
05:25 AM Emil: wat
05:25 AM Emil: yeah but
05:26 AM Emil: SPDR is not buffered
05:26 AM Emil: iirc
05:26 AM LeoNerd: No
05:26 AM polprog: yes, so write, wait for tx end, write, done
05:26 AM LeoNerd: So pbviously you still wait for it to be finished
05:26 AM polprog: yes
05:26 AM Emil: LeoNerd: but I don't want to wait for finish
05:26 AM Emil: LeoNerd: that wastes cycles :D
05:26 AM LeoNerd: then use interrupt
05:26 AM Emil: but that's cancer
05:27 AM LeoNerd: also, what spi clock rate?
05:27 AM LeoNerd: spi is fast
05:27 AM Emil: LeoNerd: this is on principle!
05:27 AM Emil: With uart I can do
05:27 AM LeoNerd: usually less cpu to wait for it, than interrupt
05:27 AM LeoNerd: yes, uart is dlooooow
05:27 AM Emil: https://emil.fi/jako/kuvat/2017-08-22_12-56-36_wriW1Mm0.png
05:27 AM Emil: I want to do the same with SPI
05:27 AM LeoNerd: i usually spi at fcpu / 4
05:27 AM polprog: umm
05:27 AM LeoNerd: that's one byte in 32 instructions
05:28 AM LeoNerd: more effucient just to wait
05:28 AM polprog: replace UCSR with SPDR
05:28 AM polprog: ?
05:28 AM LeoNerd: ISR overhead is worse than that unless you hand-roll it really well
05:28 AM polprog: wait duh
05:29 AM LeoNerd: UART byte rates go into hundreds of instructions per byte, so they work better interrupt-driven
05:30 AM polprog: Emil: cant you just write to SPDR, wait for it to end transmitting and write the byte again?
05:30 AM LeoNerd: I²C also
05:32 AM Haohmaru: Emil pre-write block
05:33 AM LeoNerd: ohyes also that saves a tiny bit of timr
05:33 AM LeoNerd: time
05:33 AM Haohmaru: that is.. { busy_wait(); spi_write(x); return; /* yey */ }
05:33 AM LeoNerd: is what I do :)
05:33 AM polprog: Emil: https://puu.sh/xgsIR/c1fb0b8121.png
05:33 AM Haohmaru: so if you're not naughty, you won't hit the penalty
05:34 AM Emil: polprog: I can
05:34 AM Emil: polprog: I don't want to
05:34 AM polprog: why
05:35 AM Emil: because _cycles_
05:35 AM polprog: hurr durr 32 cycles overhead
05:35 AM polprog: if you wanna use all cycles then bitbang it in assembly
05:35 AM Emil: I'm actually using SPI2X so it's only 16
05:35 AM Emil: but MUH _CYCLES_
05:35 AM polprog: that's even more silly explanation :D
05:35 AM Haohmaru: muh precious cycles
05:35 AM LeoNerd: You can use those cycles to get the next byte ready
05:35 AM Emil: Haohmaru: yes but
05:36 AM Emil: busy_wait
05:36 AM Emil: how can I detect
05:36 AM polprog: oh LeoNerd's idea is good
05:36 AM Emil: if transmission is going
05:36 AM LeoNerd: Getting the next byte from a buffer probably takes at least 4
05:36 AM polprog: you cant
05:36 AM Emil: T.T
05:36 AM Emil: Fug dis
05:36 AM LeoNerd: more if you need to calculate it
05:36 AM Emil: Atmel y u do tis
05:36 AM Emil: Ima make a state machine
05:36 AM LeoNerd: there is a busy bit
05:36 AM Haohmaru: Emil busy_wait() is your equivalent of while (spi_busy) { NOP; }
05:36 AM Emil: LeoNerd: it's only for when transmission is going on
05:36 AM LeoNerd: that is what the standard code does
05:37 AM Emil: Haohmaru: yes but SPIF can and is cleared by default
05:37 AM LeoNerd: Isn't that what you just asked?
05:37 AM polprog: Emil: what's your point
05:37 AM Emil: https://emil.fi/jako/kuvat/2017-08-22_13-06-43_kTIVPtaK.png
05:38 AM Emil: This is what is currently looks like: https://emil.fi/jako/kuvat/2017-08-22_13-07-05_7opTX1ak.png
05:38 AM Haohmaru: the while loop is your busy_wait()
05:38 AM Emil: Haohmaru: you can't do that first :D
05:38 AM Haohmaru: move it up ;P~
05:38 AM Emil: Haohmaru: you can't :D
05:39 AM Emil: SPIF is cleared by default
05:39 AM Emil: it will enter an infinite loop
05:39 AM Haohmaru: uhm, what will happen then?
05:39 AM Haohmaru: wait, this is on some atmega i guess
05:39 AM Emil: Yes
05:39 AM Haohmaru: i think there are more options on xmega..
05:39 AM Emil: m328p
05:40 AM Emil: Haohmaru: lol, no doubt :D
05:40 AM LeoNerd: xmega can do DMA
05:40 AM Haohmaru: i'm doing mostly xmega here ;P~
05:40 AM LeoNerd: You can't do better without that on ATmega
05:41 AM Emil: LeoNerd: I fucking can if I add a state machine
05:41 AM Emil: But that's pussyboi strategy T.T
05:41 AM Haohmaru: why not use interrupt?
05:41 AM LeoNerd: I don't understand what yiu mean to do
05:41 AM Haohmaru: or USART in SPI mode
05:42 AM Emil: LeoNerd: I want to fire and forget
05:42 AM LeoNerd: Haohmaru: you know that's slower than busywait, yes?
05:42 AM Emil: LeoNerd: set up byte and let it transmit on its own
05:42 AM Haohmaru: the USART on xmega has interrupt on transmit complete
05:42 AM LeoNerd: That /is/ how the SPI unit works
05:42 AM Emil: LeoNerd: well actually it depends but in general if you are out of luck it's slower than busywait
05:42 AM Emil: LeoNerd: you don't understand
05:43 AM LeoNerd: if you write to SPDR then never touch it again that will happen
05:43 AM Emil: LeoNerd: I want to do shit after I have issued a transmit
05:43 AM Emil: LeoNerd: but I might want to send something else, too
05:43 AM LeoNerd: GAAAAHHHH
05:43 AM Emil: LeoNerd: gah back at you
05:43 AM Haohmaru: use pre-write block plus an additional flag in RAM
05:43 AM Haohmaru: </idea>
05:43 AM Emil: Haohmaru: yes, state machine
05:44 AM Emil: plus whatcha mean with pre-write block
05:44 AM Haohmaru: is that what you meant with state machine?! o_O
05:44 AM LeoNerd: I'm really not following this at all now
05:44 AM LeoNerd: The way you write SPI usually is that you busywait (or interrupt) until the SPI unit is free, then write your byte to SPDR then THAT IS IT
05:44 AM LeoNerd: If you want to write more bytes you do the same again
05:45 AM LeoNerd: That busywaiting will take you 16 cycles MINUS WHATEVER TIME IT TOOK to generate more data
05:45 AM Haohmaru: uint8_t meh = 0; ... void fancy_write(x) { while (spi_busy && meh) { NOP; } spi_write(x); meh = 1; }
05:45 AM LeoNerd: I put it to you that generating more data is likely to be at least 16 cycles ANYWAY
05:45 AM Haohmaru: something like that
05:45 AM LeoNerd: At which point you keep the SPI unit entirely busy 100% of the time
05:45 AM LeoNerd: Every moment it has finished sending one byte, you've *already* got the next byte ready for it
05:45 AM Haohmaru: but i haven't had enough coffee yet
05:46 AM LeoNerd: Whatever else you're going to do, if you really truely believe you can timeslice it inbetween those FEWER THAN 16 CYCLES then go for it. But I really doubt you can
05:46 AM LeoNerd: You already said you're doing fCPU/2, so that really is 16 cycles at most you have.
05:47 AM LeoNerd: These sorts of arguments apply a lot less to I²C and UART moreso, purely because those hundreds or thousands of spare cycles you have give you plenty of time to think about other things, use interrupts, etc etc
05:48 AM LeoNerd: But SPI (especially at fCPU/2) is literally *too fast* for you to have time to do anything other than talk to the SPI unit
05:48 AM Haohmaru: i say use an xmega at moar MHz so that you get moar cycles
05:48 AM Haohmaru: ;P~
05:48 AM LeoNerd: Yes - if you're on an XMEGA then you can use the DMA unit, say, to squirt out entire chunks of prerendered content over SPI without CPU involvement
05:48 AM LeoNerd: Typically that's useful for static strings out of program memory, or other such
05:49 AM LeoNerd: Again, if you're talking at the fast fCPU/2 rate, you're unlikely to be able to generate data as fast as that anyway, so DMA buys you nothing
05:49 AM Haohmaru: because atxmega has MOAR x than atmega!!1one
05:49 AM Emil: LeoNerd: mate
05:49 AM Emil: LeoNerd: you need a flag to know if your spi is free
05:49 AM LeoNerd: do you want me ot paste you my c function?
05:49 AM Emil: why not
05:50 AM Emil: LeoNerd: I understand just fine how SPI works
05:50 AM LeoNerd: Do you want a really really big hint?
05:50 AM Emil: When you first want to use SPI SPIF is cleared
05:50 AM Emil: So you can't busy wait on it
05:50 AM LeoNerd: In setup() - clear all the SS lines, write a zero into SPDR
05:50 AM LeoNerd: Then you *know* SPIF will be set :)
05:50 AM LeoNerd: You ensure the flag is set on STARTUP
05:50 AM Emil: LeoNerd: yes but that sends shit out
05:50 AM LeoNerd: And?
05:51 AM LeoNerd: With no SS lines asserted, nobody cares
05:51 AM Emil: That's pussyboi strat T.T
05:51 AM Emil: But sure, fine, that wokrs
05:51 AM LeoNerd: Alternatively, use a different function to write the first byte of a transfer, than every other function
05:51 AM Emil: That's even more kludge
05:51 AM LeoNerd: *every other byte
05:52 AM Haohmaru: why do i have the feeling that you're not using the SPI module for.. SPI..?
05:52 AM Emil: I am
05:52 AM Haohmaru: wouldn't you be happy with USART in spi mode then?
05:53 AM LeoNerd: Maybe someone on avrfreaks would have another idea
05:53 AM Haohmaru: with transmit complete interrupt/flag
05:53 AM LeoNerd: Oherwise that's about all I've got
05:53 AM Emil: LeoNerd: sending 0 on init is fine
05:53 AM LeoNerd: Right. Are we happy then?
05:54 AM Emil: No
05:54 AM Emil: It's kludge
05:54 AM Haohmaru: >:(
05:54 AM * Haohmaru turns green
05:54 AM Emil: But apparently you can't do better
05:55 AM Haohmaru: Emil how many MHz are you running at?
05:55 AM LeoNerd: Also, I'm reasonably sure the *absolute smallest* ISR for transmitting "the next byte" out of a buffer is 18 instructions, if I count on my fingers,.. and that doesn't actually include checking we're at the end yet
05:55 AM LeoNerd: Hmmm
05:55 AM LeoNerd: Soyeah, at fCPU/2 it's literally impossible to do SPI any faster than busywait
05:55 AM Haohmaru: how about those nekkid interrupt things?
05:56 AM LeoNerd: You might *juuuust about* be able to squeeze some useful work in between that at fCPU/4
05:56 AM LeoNerd: Haohmaru: that was naked
05:56 AM Emil: LeoNerd: it's about not unnecessary waiting for end of transmit
05:56 AM Haohmaru: ah
05:57 AM LeoNerd: ISR context switch (2); push {a temporary}; push {r28, r29}; load {buffer addr} to r28+r29; load next byte with postinc from Y; mov to SPDR; save {buffer addr} back from r28+r29; pop {r29, r28, temp}; reti
05:57 AM LeoNerd: I -think- that's 18 cycles
05:57 AM LeoNerd: Now add to that the atleast 3 cycles you'll need to compare if the pointer is at the end of a buffer - we can use a compiletime constant for "the end" for maximum speed
05:57 AM LeoNerd: 21 cycles
05:58 AM LeoNerd: .. 22 because of conditional jump
05:58 AM LeoNerd: OK so yeah, we can get 10 cycles of real work done per SPI byte, at fCPU/4
05:58 AM Emil: And possibly +1/2 cycles if the instruction you are executing requires that
05:58 AM LeoNerd: Mhm
05:59 AM * LeoNerd would expect *someone* on avrfreaks to have discussed this issue
06:03 AM LeoNerd: (somewhat annoying that the weird nature of interrupt flag registers means you can't just preset the flag :/)
06:03 AM LeoNerd: Oh.. I suppose for a 2 cycle overhead you could just remember that
06:04 AM LeoNerd: void spi_out(uint8_t x) { static bool first = true; if(first) first = false; else {busywait on SPIF}; SPDR = x; }
06:05 AM LeoNerd: But that's subtle and relies on you not clearing the flag for other reasons elsewhere
06:05 AM LeoNerd: and also on you never reading in other parts of the program
06:06 AM * LeoNerd also, idly, ponders a theme of flow control between AVR-implemented SPI master and slave
06:07 AM Haohmaru: overclock the atmega!
06:07 AM LeoNerd: Well the slave is an ATtiny
06:07 AM Haohmaru: that was for Emil
06:07 AM LeoNerd: It's a tiny841, acting as a DMX512 bridge
06:07 AM Haohmaru: moar clocks
06:07 AM LeoNerd: I currently just have to talk to it slowly
06:12 AM Haohmaru: Emil didn't YOU say that you'd use an ARM for everything? ;P~
06:12 AM Emil: Haohmaru: yes
06:12 AM Haohmaru: >:)
06:12 AM Emil: Haohmaru: I would use an ARM for everything
06:12 AM Emil: If I could
06:13 AM Emil: If I knew how to
06:13 AM Haohmaru: oh that's a very SLIGHT detail there
06:13 AM Haohmaru: ;P~
06:13 AM Emil: No it's clear
06:13 AM Emil: ARMs are better at everything but development
06:49 AM Lambda_Aurigae: http://hackaday.com/2017/08/22/laser-etching-pcbs/
06:49 AM Lambda_Aurigae: new twist on making PCBs with lasers.
06:49 AM Lambda_Aurigae: paint the PCB
06:49 AM Lambda_Aurigae: then laser etch the paint
06:49 AM Lambda_Aurigae: then etch the underlying copper
06:50 AM Lambda_Aurigae: chemically.
06:50 AM HelloShitty: Hello
06:50 AM HelloShitty: I have a question about mega328
06:50 AM HelloShitty: I need to control an external device with the mega328
06:51 AM HelloShitty: but I have some concerns about using some of the pins of mega328
06:51 AM Emil: HelloShitty: m328p probably
06:51 AM Emil: Yes what is your question
06:51 AM HelloShitty: for instance, I'm using an USB-to-Serial converter, so I'm using pins Rx and Tx of the (yes the m328p) AtMega328
06:52 AM Emil: say m328p if you mean m328p, 328 is not the same as 328p but yes continue
06:52 AM Emil: That would be correct
06:52 AM HelloShitty: can I still use the PD0 and PD1 to control this external device?
06:52 AM Emil: No
06:52 AM Emil: Well
06:52 AM Emil: It depends
06:52 AM Emil: yes and no
06:52 AM Emil: but if you are asking about this then it's mostly no
06:53 AM HelloShitty: hum, ok those should be technical details I'm not well aware about
06:53 AM HelloShitty: ok, so let's try to clear this out
06:53 AM HelloShitty: I'm jusst a noob
06:53 AM Emil: Yes I figured
06:53 AM Emil: Well, first of all
06:53 AM HelloShitty: and starting to do something real with the m328p
06:53 AM Emil: I recommend you don't use those pins
06:53 AM HelloShitty: First of all, I bought a few uC from ebay
06:54 AM HelloShitty: they say AtMega328p
06:54 AM Emil: But just for the serial to usb chip
06:54 AM * Haohmaru paints Lambda_Aurigae with some paint
06:54 AM HelloShitty: and when I upload code, using avrdude
06:54 AM Haohmaru: now where's my lazor
06:54 AM HelloShitty: I use m328p in the command
06:54 AM LeoNerd: The 328p is generally fairly-well thought out in terms of pin multiplexing
06:55 AM LeoNerd: I've usually not had much trouble with peripheral clash on it
06:55 AM * LeoNerd glares at 32U4 by comparison
06:55 AM HelloShitty: So, if I make a code where I say that PORTD is all output
06:56 AM HelloShitty: can't I then uopload code to the uC?
06:56 AM HelloShitty: Let me be more accurate with what I need, and what I'm doind
06:56 AM HelloShitty: doing
06:56 AM HelloShitty: I'm building a small circuit, on the breadboard for now
06:57 AM HelloShitty: that uses an AD9850 module, also bought on ebay
06:57 AM HelloShitty: and I'm using the m328p (or AtMega328p, also bought from ebay) to control it
06:58 AM HelloShitty: So I need 4 pins of the the m328p to control the W_CLK, DATA, FU_UP and RESET pins of the AD9850
06:58 AM HelloShitty: The catch is that I placed the parts in a way that is more handy to me to use PORTD pins to control the AD9850
06:58 AM LeoNerd: You can still use four of them
06:59 AM HelloShitty: because of the distance involved and the length of the wires I have here
06:59 AM LeoNerd: E.g. PD4 to PD7 would be fine
06:59 AM Lambda_Aurigae: so, you want to control something with the same pins used by the uart?
06:59 AM HelloShitty: LeoNerd: there is the XTAL in PD6 and PD7
07:00 AM LeoNerd: PB6/7
07:00 AM HelloShitty: Lambda_Aurigae: that was what I was asking about... If it was possible
07:00 AM HelloShitty: ah sorry LeoNerd
07:00 AM polprog: it's possible, you just have to disable uart
07:00 AM Haohmaru: yes, but the pin cannot play two roles at the same time
07:00 AM LeoNerd: The PD4-7 range is often quite convenient for a 4bit IO range like this
07:00 AM LeoNerd: I sometimes have buttons there, for example
07:01 AM Lambda_Aurigae: you will also need to disconnect the usb-uart device most likely to eliminate conflicts...or disable it.
07:02 AM HelloShitty: hum, ok
07:02 AM LeoNerd: I'm not following the question at all
07:02 AM HelloShitty: So, I think I'll try to find longer wires
07:02 AM Haohmaru: yea, generally, try not to get a situation where two outputs get connected together
07:02 AM Haohmaru: ..two or more
07:02 AM LeoNerd: Yuo can connect a peripheral to PD4-PD7 ENTIRELY UNRELATEDLY to whatever USART is doing on PD0/PD1
07:02 AM LeoNerd: They are different pins
07:03 AM HelloShitty: yes LeoNerd
07:03 AM Lambda_Aurigae: if you output to the TX pin and the usb adapter sees that pin toggling it is going to think there's data coming in.
07:03 AM HelloShitty: the catch was only the distance involved
07:03 AM HelloShitty: you know?
07:03 AM LeoNerd: ...no?
07:03 AM HelloShitty: I need longer wires to reach PD5/6/7
07:04 AM LeoNerd: ... how big is your chip?
07:04 AM LeoNerd: Are we talking meters long??
07:04 AM polprog: he's breadboarding
07:04 AM Lambda_Aurigae: if you have something attached to the RX pin,,external to the atmega, and you start sending data from the computer over the usb adapter, that external device will see the pin toggling and think it's being controlled.
07:04 AM HelloShitty: because I placed the AD9850 module in one end of the breadboard
07:04 AM HelloShitty: and the mega328p at the other end
07:04 AM HelloShitty: IT was just that
07:04 AM polprog: you can move them close :D
07:04 AM HelloShitty: but no problem
07:04 AM HelloShitty: I'll get longer wires
07:04 AM Lambda_Aurigae: so get a piece of cat5e cable and make your own wires.
07:04 AM Lambda_Aurigae: I do it all the time.
07:05 AM Lambda_Aurigae: just make sure it's solid core and not stranded cat5e
07:05 AM Haohmaru: and you're still standing strong ;P~
07:05 AM HelloShitty: I have more circuitry in between
07:05 AM Lambda_Aurigae: I haven't electrocuted myself...shocked a few hundred times, but never electrocuted.
07:05 AM HelloShitty: I have a wheatstone bridge or whatever it is called
07:05 AM polprog: yes, it's pointless to buy premade wires, they are too expensive
07:05 AM HelloShitty: and 2 OpAmps
07:06 AM HelloShitty: and also some decoupling caps and stuff in the middle
07:06 AM HelloShitty: so, there is not much room available
07:06 AM Haohmaru: get moar breadboards
07:06 AM Lambda_Aurigae: I have a dozen or more here.
07:06 AM HelloShitty: I don't
07:06 AM Haohmaru: i got.. four maybe
07:07 AM Lambda_Aurigae: buy them 10 at a time.
07:07 AM Lambda_Aurigae: then end up giving them away to kids I teach.
07:07 AM HelloShitty: I only have 3 and all of them are somehow used
07:07 AM Haohmaru: yup, one more breadboard is never too much
07:07 AM HelloShitty: ok, I'm going to make longer wires
07:08 AM Lambda_Aurigae: https://www.circuitspecialists.com/wb-102+j.html
07:08 AM HelloShitty: and move the control pins to PD4-7
07:08 AM Lambda_Aurigae: I buy those 10 or 20 at a time once a year or so.
07:08 AM Lambda_Aurigae: and have LOTS of wires...hehe
07:09 AM polprog: i just buy a meter of cat5 every now and then
07:09 AM polprog: hmm i havent breadboarded anything for a long time
07:09 AM HelloShitty: a friend of mine also gave me what it looks to be a set of cat5 RJ45 cable wires
07:09 AM Haohmaru: u shall be punished, polprog
07:10 AM HelloShitty: Usually I make small wires to the +Vxx and to GND
07:11 AM HelloShitty: then the other wiers are longer and makes the breadboard circuits to look like rat nests
07:11 AM HelloShitty: lol
07:11 AM Lambda_Aurigae: I have a spool of cat5e in the shed...started at 1000 feet some years back.
07:11 AM Lambda_Aurigae: have another in the truck that I've used half of this year already.
07:11 AM Haohmaru: i even use amputated component legs to connect stuff on the breadboard to the power lines
07:11 AM Haohmaru: ;P~
07:11 AM HelloShitty: ok, let me try to fix this and then I have a lot more questions to ya guys
07:11 AM HelloShitty: btw, where ya'll are from?
07:12 AM Haohmaru: 127.0.0.1
07:12 AM polprog: ::1
07:12 AM HelloShitty: I'm from a small country named Portugal
07:12 AM HelloShitty: ahah, ok
07:12 AM Lambda_Aurigae: 10.0.0.101 here.
07:12 AM HelloShitty: good enough
07:12 AM Emil: Gah
07:12 AM Emil: I hate when DACs behave like shite
07:13 AM polprog: 10.5.255.92, what the hell router
07:13 AM Lambda_Aurigae: and I hate it when I realize I gotta head to work in 5 minutes!
07:13 AM Lambda_Aurigae: laters.
07:13 AM polprog: that's an odd choice
07:13 AM Emil: Well, at least on 1x gain (same resolution, really) this one doesn't exhibit too bad behaviour
07:13 AM polprog: later lambda
07:13 AM Haohmaru: polprog your router is drunk
07:13 AM polprog: it's not mine, isp given at the grandparents
07:13 AM Haohmaru: doesn't matter
07:14 AM Haohmaru: someone might have spilt vodka on it
07:14 AM polprog: isp given meaning i havent got my hands on it to configure it properly :D
07:14 AM Haohmaru: i know
07:14 AM Haohmaru: i got the same sort of router at home
07:14 AM polprog: also, if you spill vodka it's bad.... you should stop at that point
07:15 AM Haohmaru: i don't ;P~
07:15 AM polprog: me neither :D
07:20 AM HelloShitty: Ok, I needed to change a little bit the wires, because I also PD6 and PD7 for analog purposes
07:20 AM HelloShitty: so I changed these 2 wires to another location
07:20 AM LeoNerd: Er... PD6/7 aren't analog pins
07:21 AM HelloShitty: The data sheet says they are? :s
07:21 AM LeoNerd: The only analog pins on a 328p are the PORTC ADC mux ones, plus the analog-only ADC6/7 pins you get on some of the package variants
07:23 AM polprog: what do you mean by analog purposes
07:23 AM HelloShitty: to read the output of the 2 OpAmps I have in the circuit
07:24 AM polprog: well, that's the adc's job
07:24 AM HelloShitty: I have printed the small version of the datasheet of this uC
07:24 AM polprog: i never used 328p so i dont know
07:24 AM polprog: ask leonerd
07:24 AM HelloShitty: and in one of the pages they have a pin out diagram
07:24 AM HelloShitty: with a subtitle with some colours
07:25 AM * LeoNerd has used the 328P solidly the past ~6 years; knows it almost inside-out
07:25 AM HelloShitty: they have light blue and light greean as Digital and Analog respectively
07:25 AM LeoNerd: The analog pins are PORTC. Not PORTD
07:25 AM HelloShitty: ok, I believe you of course
07:26 AM HelloShitty: I'm saying what I'm looking at to tell you why I thought those were analog pins
07:26 AM LeoNerd: Possible it's a printing error? Or a C and become a D or something?
07:27 AM polprog: i always like to pull up the datasheet on my laptop
07:27 AM polprog: also, what kindof datasheet has colored pins
07:27 AM LeoNerd: I have a lot of the pinout diagrams printed on my wall :)
07:27 AM LeoNerd: polprog: the newer Atmel sheets are using colour to identify different kinds of pins
07:27 AM Emil: HelloShitty: a) you can't read b) you printed from a shite source c) your printer is bad
07:27 AM LeoNerd: power/ground, programming, analog, etc..
07:27 AM Emil: HelloShitty: select your pick
07:27 AM polprog: i have a small folder with printed cheat sheets, pinouts, instruction set table
07:28 AM polprog: http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf
07:28 AM HelloShitty: http://www.atmel.com/images/atmel-42735-8-bit-avr-microcontroller-atmega328-328p_summary.pdf
07:28 AM HelloShitty: this is what I printed
07:28 AM HelloShitty: page 9
07:28 AM Emil: HelloShitty: yes, those contain Analog comparator pins
07:28 AM polprog: ah those are ain0/1
07:28 AM Emil: https://emil.fi/jako/kuvat/2017-08-22_14-57-55_evIiXBZT.png
07:28 AM LeoNerd: Oooooh the anacomp
07:29 AM Emil: ADC pins say ADC
07:29 AM Emil: https://emil.fi/jako/kuvat/2017-08-22_14-58-03_GEh9Y9Mj.png
07:29 AM LeoNerd: ... Yah; it's debatable whether you'd consider the anacomp pins to be "analog" pins
07:29 AM Emil: LeoNerd: they are
07:29 AM Emil: LeoNerd: they are tied to the analog subsystem
07:29 AM Emil: So HelloShitty you selected a)
07:29 AM Emil: With d) you assume sprinkled on top
07:30 AM LeoNerd: I suppose from the point of view that their purpose depends on an analog input level, they are analog pins
07:30 AM LeoNerd: But they're not part of the ADC
07:30 AM Emil: Of course not
07:31 AM LeoNerd: I suppose by that point, any chip with a DAC you'd start splitting hairs on the DACOUT pin
07:31 AM LeoNerd: ... but then I don't know of any ATmega with a DAC :(
07:31 AM Emil: I wish AVRs had a DAC
07:31 AM LeoNerd: I believe some of the XMEGAs have one
07:31 AM Emil: there's already a bloody dac in the ADC system
07:31 AM Emil: LeoNerd: all of them do iirc
07:31 AM LeoNerd: Ah.. ish.
07:31 AM LeoNerd: The DAC in the ADC isn't a real DAC though
07:32 AM LeoNerd: The ADCs are deltasigmas, so they don't need a full DAC to work
07:32 AM LeoNerd: The deltasigma converter is more like a "PWM DAC" output and a comparitor, attached to a little controller of their own
07:33 AM LeoNerd: If you only needed low-speed analog output you can also use a PWM pin to good effect
07:33 AM Emil: päärrrrrrrrrrrrrrr
07:34 AM LeoNerd: In fact I have a rather cunning plan that involves making an 18bit DAC out of two PWM controllers
07:34 AM HelloShitty: Well, so I need to change again those 2 wires
07:34 AM HelloShitty: I'm sorry for my noob
07:34 AM LeoNerd: If you put them in fast 12bit mode you can *sortof* get 24 bits out of it, but that gives you no overlap to account for errors
07:34 AM HelloShitty: It's what I am
07:34 AM LeoNerd: So you instead overlap them closer at something like 10bits each
07:34 AM HelloShitty: So it's expected errors and wrong assumprions from me
07:35 AM Haohmaru: Emil xmegas have DACs
07:35 AM LeoNerd: HelloShitty: mistakes are an excellent source of learning material :)
07:35 AM * Haohmaru waves the xmega flag
07:36 AM HelloShitty: I hope so LeoNerd
07:36 AM Haohmaru: and a voltage comparator is analog, otherwise it must be some kind of logical comparator ;P~
07:36 AM LeoNerd: Haohmaru: I guess I view it from the point of view of the program running on the MCU; the anacomp gives a digital yes/no result
07:36 AM Emil: Haohmaru: yes, I already said that
07:36 AM HelloShitty: so, I changed those 2 wires to PC0 and PC1
07:36 AM Emil: LeoNerd:
07:37 AM Emil: LeoNerd: just buy a DAC
07:37 AM LeoNerd: Emil: an 18bit DAC?
07:37 AM LeoNerd: Actually I sortof want 20bits but the hardware might not quite justify it
07:37 AM Emil: LeoNerd: MCP4822
07:37 AM Emil: http://ww1.microchip.com/downloads/en/devicedoc/21953a.pdf
07:37 AM Haohmaru: LeoNerd it takes a variable voltage input and has a logic output
07:37 AM Emil: LeoNerd: that's what I'm playing with _Right_Now_
07:39 AM LeoNerd: Emil: that's 12bit
07:39 AM LeoNerd: It says right there on the title
07:39 AM Haohmaru: u dirty liar!
07:39 AM Emil: LeoNerd: read the datasheet, pleb
07:39 AM Haohmaru: it's too long
07:40 AM Haohmaru: and too microchippy
07:40 AM Emil: https://emil.fi/jako/kuvat/2017-08-22_15-09-14_srw2eOHb.png
07:40 AM LeoNerd: Oh the dualing trick at the bottom
07:40 AM LeoNerd: Yes; that's the same trick I'm doing
07:40 AM Emil: It's not PWM shite
07:40 AM Emil: though
07:40 AM LeoNerd: I'm just doing it with the inputs being two PWM channels that I get for free out of my MCU
07:40 AM LeoNerd: You say "shite"
07:40 AM LeoNerd: PWM'ed DAC is *very* good for linearity at slow rates
07:41 AM LeoNerd: I only need slow rates
07:41 AM LeoNerd: I want a stable DC signal under human-input control. It only has to be able to change as fast as I can type numbers
07:41 AM LeoNerd: But I do want it very linear, and that's something a PWM can do *far* better than a resistor chain in a current-style DAC
07:41 AM Haohmaru: what if you're a ninja h4x0r?
07:41 AM Emil: LeoNerd: Well, okay, good point
07:41 AM LeoNerd: Haohmaru: well, we're still talking dozens of samples a second. Just not thousands
07:42 AM * polprog would use a bunch of 595s and an r2r ladder /s
07:43 AM LeoNerd: polprog: and you'll get 18bits of linearity out of an R-2R ladder... how? ;)
07:43 AM polprog: joking
07:43 AM polprog: no idea what are you talking about :<
07:43 AM LeoNerd: PWM guarantees monotonicity also. R-2R is terrible at that
07:43 AM Haohmaru: what does that mean exactly?
07:44 AM LeoNerd: monotonicity - the transfer function is monotonic
07:44 AM Emil: That the output is always growing on input
07:44 AM Haohmaru: aren't there resistor arrays in r2r formations? ;P~
07:44 AM LeoNerd: I.e if you put a bigger number in you are guaranteed not to get a smaller voltage out
07:44 AM polprog: ah this monotonicity
07:44 AM LeoNerd: R-2R does *not* guarante monotonicity
07:44 AM LeoNerd: When yuo flip the MSB, for example, you can often go the wrong way on output voltage
07:45 AM LeoNerd: So when you go from 0b01111... to 0b10000... that should be a voltage increase, but maybe it isn't
07:45 AM polprog: look i have no idea about how a dac works but a blackbox model
07:45 AM LeoNerd: :)
07:45 AM LeoNerd: These aer all different ways they can be imperfect
07:45 AM polprog: similar with adc :D
07:45 AM Haohmaru: you have some idea, so it's a gray box
07:46 AM polprog: whatever.... im back to reading the book as soon as i get home
07:46 AM polprog: later
07:46 AM LeoNerd: Generally, different imperfections and limits come from different techniques. it's the usual trade-off problem
07:47 AM LeoNerd: PWM DACs are slow, but that's OK for me. The benefits of PWMing them are what I want
07:48 AM LeoNerd: Generally PWM'ing a DAC only works up to about 16 bits, because wider PWM counters are even slower adn you get ripple
07:48 AM LeoNerd: But the same "coarse + fine" tecnique this data sheet uses for combining two channels to make a better one, works just as well for any other DAC form, like PWM ones
07:49 AM LeoNerd: You can account for the inaccuracies of the coarse+fine resistor network by using an ADC for feedback, reading in the voltage you're generating and adjusting the PWM values in software
07:49 AM Haohmaru: that's perverted
07:49 AM LeoNerd: And further you don't need a fast ADC for that, as you're only accounting for resistor values, which should remain fairly constant across short term of a few seconds
07:50 AM LeoNerd: So even if your super-fancy 24bit ADC can only do 4 samples/sec, you can easily do 100 samples/sec of DAC output and just keep an eye on that output every so often
07:51 AM * Haohmaru injects some delay into LeoNerd's feedback
07:51 AM * LeoNerd oscillates
07:51 AM * Haohmaru shorts LeoNerd to ground
07:52 AM Haohmaru: ehm, i mean protective earth ;P~
07:52 AM LeoNerd: Ohyes, the other reason for using PWM DACs - they pass through digital isolators just fine :)
07:58 AM polprog: LeoNerd: the voltage follower op amp is to lower the output impedance, right?
07:58 AM polprog: in the case of that double dac circuit emil posted
08:02 AM LeoNerd: Er, I've closed it for now, but yes probably
08:03 AM LeoNerd: Again in the "ideal world" implementation if you say, want to make a 16bit DAC out of two 8bit DACs you can use a 256:1 resistor divider between the outputs to give them course and fine adjustment, then a buffer follower on the output
08:04 AM LeoNerd: But of course in the real world those resistors won't be perfect, so maybe what you do is try to use two 10bit DACs but still a 256:1 ratio, so there's some spare bits of "tuning" on both sides
08:04 AM LeoNerd: If you measure feedback (either continously in circuit, or just as a one-off calibration operation) you can characterise it for what those resistors *actually* are, and also calibrate off any asymmetry between the two DACs, and adjust the numbers you send to them
08:06 AM polprog: good to know
08:06 AM polprog: thanks :D
08:42 AM enh: hi
09:57 AM lemm|ngs is now known as lemmings
10:00 AM enh: All right?
10:10 AM polprog: hi
10:15 AM Emil: Speed routing
10:15 AM Emil: I should organize a challenge on that
10:15 AM Emil: https://emil.fi/jako/kuvat/2017-08-22_17-44-58_4xWvP5Au.png
10:15 AM Emil: Absolutely cancer
10:16 AM Emil: but it was quick
10:16 AM polprog: why cancer...
10:16 AM polprog: ?
10:16 AM polprog: also
10:16 AM Emil: polprog: look at the routing
10:16 AM polprog: not that bad
10:16 AM Emil: >not bad
10:16 AM Emil: All my hues
10:16 AM polprog: you could make FIFTH be a bit thicker
10:17 AM polprog: ok it looks crippled
10:17 AM Emil: Than you for understanding
10:17 AM Emil: It's 0.5 so it should work fine
10:17 AM polprog: it stands out in that middle of nowhere
10:18 AM polprog: but hey if it workd
10:18 AM polprog: works*
10:18 AM polprog: what exactly is wrong with it according to you
10:19 AM Emil: Cancerous routing, cancerous component placement, through hole components, Huge as fuuuuuuuck, ...
10:20 AM polprog: well it's huge as fuck
10:20 AM Haohmaru: Emil zoom out, dude
10:20 AM Haohmaru: ;P~
10:20 AM enh: cancer, fuck... Such nasty names
10:20 AM polprog: i mean... yeah, it should be smaller
10:26 AM polprog: cant you use smd components?
10:28 AM HelloShitty: Hello again
10:29 AM HelloShitty: As I'm fairly new to programming bare AVR chips
10:29 AM HelloShitty: I'll need some basic help
10:29 AM HelloShitty: for instance, if I need to pull up a pin
10:29 AM HelloShitty: like make it 1 and then 0
10:30 AM HelloShitty: and I want to write a function for this purpose
10:30 AM HelloShitty: can I do this:
10:30 AM HelloShitty: void pulse_high(uint8_t pin){
10:30 AM HelloShitty: _BV(pin);
10:30 AM HelloShitty: ~_BV(pin);
10:30 AM HelloShitty: }
10:30 AM HelloShitty: ???
10:30 AM enh: nope
10:31 AM HelloShitty: So, how is it done?
10:31 AM enh: Which ic?
10:32 AM HelloShitty: AtMega328p
10:32 AM HelloShitty: or mega328p
10:32 AM enh: got the datasheet?
10:32 AM HelloShitty: not sure what is the difference
10:32 AM HelloShitty: yes
10:32 AM enh: wait
10:32 AM HelloShitty: I have printed the short version and I have the long version onpen in laptop
10:32 AM LeoNerd: Usually you write to the PORT register
10:32 AM HelloShitty: ahh ok
10:32 AM LeoNerd: Eg.. PORTD |= _BV(5); PORTD &= ~_BV(5); to do PD5
10:32 AM HelloShitty: I think I got it
10:33 AM enh: do you have ardiuno installed?
10:33 AM HelloShitty: LeoNerd: first is to set it as 1, and the other to set it as 0, correct?
10:33 AM LeoNerd: First sets it high, second sets it low again yes
10:33 AM HelloShitty: enh: the Arduino IDE?
10:33 AM HelloShitty: yes
10:35 AM enh: Look for a file called iom328p.h
10:35 AM HelloShitty: ok
10:35 AM LeoNerd: You could if you wanted; but you could also note that the names of the registers in there all match the names in the data sheet
10:36 AM LeoNerd: You generally don't need to go poking in the .h file; you can just write code by reading the names out of the data sheet directly
10:36 AM HelloShitty: indeed
10:36 AM enh: I redefined some of the arduino stuff for my project:
10:36 AM LeoNerd: Certainly I never normally bother
10:36 AM enh: #define GPIO3_PORT PORTC
10:36 AM enh: #define GPIO3_PORTPIN PC0
10:36 AM enh: #define GPIO3_DDR DDRC
10:36 AM enh: #define GPIO3_IS_INPUT cbi(GPIO3_DDR, GPIO3_PORTPIN);
10:37 AM enh: #define GPIO3_IS_OUTPUT sbi(GPIO3_DDR, GPIO3_PORTPIN);
10:37 AM enh: #define GPIO3_TIMER_OFF ERR_NOT_A_TIMER
10:37 AM enh: #define GPIO3_TIMER_ON ERR_NOT_A_TIMER
10:37 AM LeoNerd: enh: please don't paste
10:37 AM enh: #define GPIO3_ADC ADC0
10:37 AM enh: #define ADCMUX_SEL_GPIO3 ADMUX = (DEFAULT << 6) | (0 & 0x07)
10:37 AM enh: #define GPIO3_HIGH sbi(GPIO3_PORT, GPIO3_PORTPIN);
10:37 AM enh: #define GPIO3_LOW cbi(GPIO3_PORT, GPIO3_PORTPIN);
10:37 AM enh: sorry
10:37 AM LeoNerd: also the sbi/cbi macros are discouraged these days. You don't need them
10:37 AM LeoNerd: gcc is quite good enough to work those out on its own
10:37 AM enh: mine does not
10:37 AM LeoNerd: Is it from the 1980s?
10:37 AM enh: avr-gcc complained
10:38 AM enh: i had to keep the definitions
10:38 AM LeoNerd: ??
10:38 AM LeoNerd: I mean: don't use cbi() or sbi()
10:38 AM LeoNerd: E.g. instead you'd #define GPIO3_HIGH do { GPIO3_PORT |= _BV(GPIO3_PORTPIN); } while(0)
10:38 AM enh: LeoNerd: use what instead?
10:38 AM LeoNerd: The regular bit ops
10:38 AM enh: ah.
10:39 AM enh: But I use them elsewhere
10:39 AM enh: So I kept
10:39 AM LeoNerd: gcc is perfectly capable of realising that a single-bit twiddle like that on those port registers is imlpemented using the SBI or CBI instructions
10:39 AM enh: hum...
10:39 AM enh: Everyday I learn something new here
10:39 AM LeoNerd: :)
10:39 AM enh: I 'll try, LeoNerd. Thanks
10:42 AM enh: HelloShitty: I redefined all that stuff for my pet project. If curious, visit https://hackaday.io/project/11724-yauvc-yet-another-unmanned-vehicle-controller. Code is there. Open source.
10:44 AM enh: Someone should make an app for pasting online. I'd keep it open all day
10:59 AM polprog: puush has an api and several apps were made
11:05 AM HelloShitty: Guys, is this accepted by the compiler?
11:05 AM HelloShitty: uint32_t freq = (frequency * 125*10^6) / 2^32;
11:05 AM LeoNerd: surely an easy way to test :)
11:06 AM HelloShitty: Or do I need to type the values the hard way like 125000000 and 4294.....
11:06 AM HelloShitty: ok
11:06 AM polprog: let me call the compiler company
11:06 AM bss36504: HelloShitty: That ^ is a bitwise xor
11:06 AM bss36504: not an exponent
11:06 AM HelloShitty: yeah, indeed
11:06 AM LeoNerd: (1LL<<32) for the latter
11:06 AM LeoNerd: The LL because otherwise it's too big
11:06 AM bss36504: some C compilers support ^^ for exponents, WMMV
11:06 AM LeoNerd: You'll also want to cast (uint64_t)frequency so it does the multiply operation in 64bits
11:07 AM HelloShitty: ok
11:09 AM HelloShitty: uint32_t freq = ( (uint64_t) frequency * 125000000) / 4294967296;
11:09 AM LeoNerd: I'd write that uint32_t freq = ((uint64_t)frequency * 125000000) / (1LL << 32);
11:09 AM polprog: less magic numbera
11:09 AM polprog: numbers*
11:10 AM LeoNerd: Annoyingly, C compilers don't like 125E6 as integers
11:10 AM HelloShitty: I haven't replaced the 1LL << 32 because I didn't understood it
11:10 AM LeoNerd: It's 1 shifted up 32 times;
11:10 AM LeoNerd: I.e. 2 to the power 32
11:10 AM HelloShitty: hum, ok
11:10 AM HelloShitty: I also learn a lot everyday
11:10 AM HelloShitty: heheh
11:10 AM LeoNerd: 1 << 32. Except that as a notation doesn't quite work, because 1 is a plain int there
11:10 AM polprog: we all do
11:10 AM LeoNerd: It has to be a long long int
11:10 AM LeoNerd: (long long)1 << 32
11:10 AM LeoNerd: 1LL for short, because it's a literal
11:11 AM LeoNerd: Actually thinking about it, (long)125E6 might be acceptable as a constant
11:11 AM HelloShitty: ok
11:11 AM LeoNerd: saving the reader from having to count those zero digits
11:11 AM HelloShitty: I'll try that too
11:12 AM LeoNerd: Hopefully it doesn't become a float and pull in all manner of floating-point runtime maths into the program
11:12 AM HelloShitty: Is it possible to do 125E6L ?
11:12 AM polprog: in java you could put _ as visual separator, i think its in c too
11:12 AM LeoNerd: Yah; Perl too, but I don't think in C
11:13 AM HelloShitty: ok, can I also do 125E6L or it has to be (long)125E6?
11:13 AM LeoNerd: I don't believe 125E6L is valid
11:14 AM HelloShitty: ok
11:14 AM HelloShitty: uint32_t freq = ( (uint64_t) frequency * (long)125E6) / (1LL << 32);
11:16 AM LeoNerd: Coulddo. but at that point you might as well cast the other number constant to being a uint64_t instead, for a shorter expression; (frequency * (uint64_t)125E6) / (1LL << 32);
11:16 AM LeoNerd: Just makes it a bit less noisy
11:16 AM LeoNerd: ... waaait a moment
11:16 AM LeoNerd: Why divide by 1<<32 ?
11:17 AM LeoNerd: Why not just shift the entire *thing* by 32?
11:17 AM LeoNerd: (frequency * (uint64_t)125E6) >> 32;
11:17 AM HelloShitty: That's what datasheet says
11:17 AM HelloShitty: :s
11:17 AM HelloShitty: fOUT = (∆ Phase × CLKIN)/2^32
11:18 AM LeoNerd: Sure
11:18 AM LeoNerd: But "divide by two to the power of whatever" is just shifting down by that amount
11:18 AM HelloShitty: nice that irssi can send those funny chars
11:18 AM HelloShitty: hum, if you say so, I believe
11:18 AM LeoNerd: A rightshift by a multiple of 8 is particularly efficient in AVR, given as it's free :)
11:19 AM HelloShitty: I was just following the datasheet and some example code I found for arduino
11:19 AM LeoNerd: So >> 32 doesn't actually cost any extra runtime cycles
11:19 AM LeoNerd: Yes...
11:19 AM HelloShitty: good
11:19 AM LeoNerd: This is one of those mathematical things
11:19 AM LeoNerd: Like saying that a + a is equivalent to 2 * a
11:19 AM LeoNerd: It's literally the same result
11:19 AM HelloShitty: yeah, I know what you mean
11:20 AM HelloShitty: so, this is how it ended up
11:20 AM HelloShitty: uint32_t freq = (frequency * (uint64_t)125E6) >> 32;
11:20 AM LeoNerd: Seems good
11:20 AM HelloShitty: I think they write it that way to be more clear about what is being done
11:21 AM LeoNerd: Yes
11:21 AM LeoNerd: Expecting that the person implementing it knows how to implement that
11:21 AM HelloShitty: like 2^32 is more like "plain text" as shifting the whole explression
11:21 AM LeoNerd: Mhm
11:22 AM HelloShitty: Is that Mhm stand for anything in particular?
11:22 AM HelloShitty: Does that Mhm...
11:22 AM LeoNerd: {generic agreement}
11:22 AM HelloShitty: ok... :)
11:25 AM HelloShitty: Which are the libraries to include to be able to the _delay_ms() funtions? Is that possible here in bare mega328p? Or is this only for Arduino and I need to build my own delay funciton?
11:28 AM HelloShitty: I founf it
11:28 AM HelloShitty: found
11:28 AM LeoNerd: The _delay ones come from <util/delay.h> I believe
11:28 AM HelloShitty: #include <util/delay.h>
11:28 AM LeoNerd: That's the one :)
11:28 AM HelloShitty: yeah
11:28 AM LeoNerd: It's really just a compiletime utility in fact, it just unrolls into a big for() loop with nops in it
11:28 AM LeoNerd: It's not a runtime functino
11:28 AM LeoNerd: *function
11:28 AM HelloShitty: And I think I also need to define the F_CPU thing before, right?
11:29 AM LeoNerd: Yus
11:29 AM HelloShitty: yeah
11:29 AM LeoNerd: That's how it knows how many NOPs to insert
11:29 AM HelloShitty: I learned about nop when I learned (in school) assembly for the 8051
11:29 AM LeoNerd: I usually bring that in from the Makefile, so it's easily changed per project
11:29 AM HelloShitty: learnt maybe
11:29 AM HelloShitty: sorry my engish
11:29 AM LeoNerd: CLOCK=16000000
11:30 AM HelloShitty: I sometimes send it in the avrdude command or also in the makefile
11:30 AM LeoNerd: Then later on cflags can include -DF_CPU=$(CLOCK)
11:30 AM LeoNerd: avrdude doesn't care
11:30 AM LeoNerd: avrdude is just writing the assembled binary onto the chip itself
11:31 AM HelloShitty: but avrdude accepts that option -D F_CPU=16000000L, for example, I guess
11:31 AM LeoNerd: Err
11:31 AM HelloShitty: ok, maybe I'm conffusing with avr-gcc
11:31 AM LeoNerd: It accepts a -D flag, which means: "disable auto-erase"
11:32 AM LeoNerd: It then possibly complains afterwards that it can't find a flash file called F_CPU=16000000L on the disk
11:32 AM LeoNerd: or somesuch
11:32 AM HelloShitty: I'll show you my makefile
11:32 AM HelloShitty: I've been using lately to explore some lcd libraries some known guy wrote for AVR chips
11:32 AM HelloShitty: Peter Fleury
11:33 AM HelloShitty: anyone knows him?
11:33 AM HelloShitty: or his work?
11:34 AM HelloShitty: this is my make file
11:34 AM HelloShitty: I think I took it from AVR site
11:34 AM HelloShitty: https://pastebin.com/aW9X5RaL
11:35 AM LeoNerd: (ugh pastebin; please pick anything else next time ;) )
11:35 AM HelloShitty: I usualy also use ideone
11:36 AM HelloShitty: and paste debian
11:36 AM HelloShitty: Which you recommend?
11:36 AM LeoNerd: ideone and debian are good
11:36 AM LeoNerd: I used to like pastie.org but it seems dead these days :(
11:38 AM LeoNerd: Yah; I'd pull the clock setting out to its own variable near the top
11:38 AM LeoNerd: so you can eassily change it
11:39 AM LeoNerd: I also keep an 'install' target, which runs avrdude
11:39 AM Chillum is now known as HighInBC
11:40 AM HelloShitty: Well, I'm also not an expert with makefiles, so I only tend to change strictly what I need and what I know how to change
11:40 AM HelloShitty: otherwise, It's certain that I break the makeifle
11:40 AM HelloShitty: xD
11:40 AM HelloShitty: Is there any difference between 10e6 and 10E6 ?
11:42 AM LeoNerd: I don't believe so
11:42 AM kl0wn: no
11:42 AM HelloShitty: ok
11:44 AM HelloShitty: So, as my program doesn't deppend on any .c file other those standard io.h and delay.h, I just leave OBJ variable empty in makefile, right?
11:45 AM LeoNerd: Er. maybe? I didn't read it in detail
11:45 AM HelloShitty: I just need to add PRG = ad9850test and OBJ = ad9850test.o
11:45 AM HelloShitty: I'm going to try
11:48 AM LeoNerd: Yah that's a bit manual for my linking
11:48 AM LeoNerd: *liking
11:49 AM LeoNerd: I usually do mine with pattern substitutions and so on
11:49 AM LeoNerd: Makes for less typing :)
11:50 AM HelloShitty: yeah I know
11:51 AM HelloShitty: but I never memorized that
11:51 AM HelloShitty: I have a small tutorial made by a friend of mine on how to do that
11:51 AM HelloShitty: but I have never memorized it
11:51 AM HelloShitty: The $@ and $% or $&
11:52 AM HelloShitty: there are some of those symbols to help to make more complex makefiles
11:53 AM HelloShitty: Ok, going to share the code I have so that you guys can help me improving it and tell me if it will work, and if not, what I need to change to make it work
11:54 AM HelloShitty: I have 2 defines that are not being used, so ignored them
11:55 AM HelloShitty: it's the analog pins defines
11:55 AM HelloShitty: https://ideone.com/hGS05v
11:55 AM HelloShitty: check it please
11:55 AM HelloShitty: thanks for helping
11:55 AM HelloShitty: I also wanted to know how can I replace my lines 19 to 22 by a ternary operator
11:55 AM HelloShitty: I remember I did it in the past but can't remember exactly how
11:55 AM LeoNerd: .. you appear to be manually implementing SPI
11:55 AM LeoNerd: You could just use the SPI unit ;)
11:56 AM HelloShitty: Yeah, as I said I'm a noob, and to be honest I'm still not absolutely sure what I'm doing lol
11:56 AM HelloShitty: but now that you mention it, yes
11:56 AM HelloShitty: probably it would be simpler
11:57 AM HelloShitty: I just would need to digg about the SPI unit of the mega328 and learn the code so that I could use it
11:57 AM LeoNerd: Chapter... maybe 13?
11:57 AM LeoNerd: I forget
11:57 AM LeoNerd: 19 :)
11:57 AM HelloShitty: Another detail I'm still thinking about is the timings the datasheets talks about between cycles and pull ups and pull downs and stuff
11:58 AM HelloShitty: From the complete datasheet version?
11:58 AM LeoNerd: The socalled "setup and hold" timings, they're usually called
11:59 AM HelloShitty: ok, I'm going to try to upload that code and see what happens
11:59 AM HelloShitty: I didn't understood your last sentence
12:00 PM LeoNerd: The part of a datasheet on a digital chip that talks about timing requirements for driving signals is usually called "setup and hold" timings
12:00 PM HelloShitty: ah ok
12:00 PM LeoNerd: It talks about the "setup time", the minimum delay after the data has been set onto data lines, before you're allowed to strobe some sort of clock-like signal
12:00 PM HelloShitty: and I don't need to worry about them in my code?
12:01 PM LeoNerd: and "hold time", .. which measures something else that I forget
12:01 PM LeoNerd: Possibly
12:01 PM LeoNerd: It may be that the chip's minimum requirements are already way faster than your 16MHz CPU can clock
12:01 PM LeoNerd: Your pulse_high() may well be working at two instructions directly, so that's a single clock cycle
12:01 PM HelloShitty: and in that case I don't need to worry, right?
12:01 PM LeoNerd: That makes it .. whatever 1/16MHz is in seconds
12:01 PM LeoNerd: 1/16th of a microsecond
12:02 PM LeoNerd: 62nsec
12:02 PM HelloShitty: I may need there a delay, is that it?
12:02 PM LeoNerd: If the chip requires slower than that you'll want a delay
12:02 PM LeoNerd: at which point, using the SPI unit is probably what you wanted to do
12:03 PM LeoNerd: You can tell that what overall clocking frequency to use, and it'll slow down to that
12:04 PM HelloShitty: At page 3 of AD9850, the timing table values are all way faster if I understand what I'm reading
12:05 PM LeoNerd: This is the 120MHz DDS siggen chip?
12:05 PM Emil: https://emil.fi/jako/kuvat/2017-08-22_19-34-30_Gys533SZ.png
12:05 PM Emil: Lets see if it works
12:05 PM LeoNerd: I'd imagine a 120MHz generator ought to cope with 16MHz SPI ;)
12:05 PM Emil: https://emil.fi/jako/kuvat/2017-08-22_19-34-43_upEABQly.png
12:05 PM HelloShitty: Well, I bought it as AD9850
12:06 PM Emil: My power source is specced at 100mA
12:06 PM LeoNerd: HAH yes.. the S&T timing params want 3.5ns minimum
12:06 PM Emil: But my ESP might draw moar
12:06 PM LeoNerd: That's like... 20 times faster than your MCU can achieve here :)
12:06 PM LeoNerd: You should be good
12:06 PM Emil: Wanna know how much capacitance these two will hold
12:06 PM Emil: https://emil.fi/jako/kuvat/2017-08-22_19-35-01_R6bf4Y6F.png
12:06 PM LeoNerd: S&H, even
12:06 PM HelloShitty: ok
12:06 PM HelloShitty: Gonna try to upload the code
12:06 PM HelloShitty: just need to remember the avrdude command
12:07 PM LeoNerd: Hence why I keep a 'make install' ;)
12:13 PM HelloShitty: done
12:13 PM HelloShitty: and it's kind of working
12:13 PM LeoNerd: kindof is a start :)
12:13 PM HelloShitty: the frequency value is wrong
12:13 PM HelloShitty: I have 2 outputs in this module I bought from ebay
12:14 PM HelloShitty: one outputs a sinewave of ~4Khz
12:14 PM HelloShitty: the other outputs a wave of about ttwice the first output
12:14 PM HelloShitty: ~8Khz
12:14 PM HelloShitty: And of about 1.12V Vpp
12:18 PM LeoNerd: Well, check numbers. repeately. Watch SPI comms using an LA perhaps?
12:19 PM LeoNerd: Often when I'm working on a new chip I talk to it first from my PC over bus pirate/etc... so I get a feel for the chip, from a real computer I can debug easier
12:19 PM LeoNerd: Once I know the chip it's often quite an easy task to port that onto the AVR
12:19 PM HelloShitty: ok, the only thing wrong are the frequency values
12:19 PM HelloShitty: they are ghanging as supposed, but just to the wrong values
12:20 PM LeoNerd: Mhmm
12:20 PM HelloShitty: I get 1.5KHz, then a minute later ~4Khz
12:20 PM LeoNerd: So maybe that freq calculation was wrong?
12:20 PM HelloShitty: then 8Khz
12:20 PM HelloShitty: and lastely 33.3Khz
12:20 PM HelloShitty: maybe
12:20 PM HelloShitty: I can't even believe this is working
12:21 PM HelloShitty: it's working wrong, but it is working
12:21 PM HelloShitty: heheh
12:21 PM LeoNerd: :)
12:21 PM LeoNerd: It's always a fun moment, that first test
12:21 PM HelloShitty: I'll open a python consoleto check the calculation numbers
12:21 PM HelloShitty: yes
12:21 PM HelloShitty: but the catch is that I also bought a WiFi module from ebay
12:22 PM HelloShitty: and I couldn't make it work properly
12:22 PM LeoNerd: Don't forget to compare with a real C program on your desktop though
12:22 PM HelloShitty: like, I bought some module that uses the ESP8266 chip
12:22 PM LeoNerd: Especialyl with numbers like this, a language like python will try to be "helpful" like using floats where required, or arbitrary precision maths
12:22 PM HelloShitty: and I wanted to flash some firmware to make sure it was the lastest one
12:22 PM LeoNerd: It may be that your error is an integer rounding bug, or an overflow of some fixed number type
12:23 PM HelloShitty: so I tried to make it as if the module as a standalone
12:23 PM LeoNerd: So often best to write a C program by literally copying the AVR code, so it's doing "the same thing"
12:23 PM HelloShitty: I couldn't do it
12:23 PM HelloShitty: and I tried so many things
12:23 PM HelloShitty: search so many web links and sites and videos and stuff
12:23 PM HelloShitty: and couldn't make it
12:23 PM HelloShitty: anyway
12:23 PM HelloShitty: I want to focus now on this
12:24 PM HelloShitty: LeoNerd: I have another "net friend" that looked to my code and told me this:
12:25 PM HelloShitty: at quick glance it could be that you're shifting out the byte from the LSB to the MSB instead of the other way round in send_byte()
12:25 PM LeoNerd: HAH
12:25 PM LeoNerd: Oh possibly ;)
12:25 PM ac_slater: hey guys, I have an avr32 base MCU but my real question is about the AVR Dragon. When I flash an elf, I see the flash unlocking and erasing. I also see writing in 2 segments. When I flash a bin, it doesnt erase or unlock and tries to write the whole thing in 1 segment and fails.
12:25 PM LeoNerd: Another reason to use the SPI unit
12:25 PM ac_slater: ideas/
12:25 PM ac_slater: ?
12:25 PM LeoNerd: AVR32??
12:25 PM HelloShitty: Can you explain?
12:25 PM * LeoNerd checks the calendar "Hrm. Nope. It's 2017"
12:26 PM ac_slater: LeoNerd: not a fan of the avr32 ;)?
12:27 PM LeoNerd: It died didn't it?
12:27 PM LeoNerd: Atmel decided it was silly and went with ARMs
12:27 PM ac_slater: eh, I mean this is a new board so someone is still making them
12:28 PM ac_slater: I'm just a newbie with jtag flashing, hence my question
12:28 PM ac_slater: :(
12:30 PM HelloShitty: LeoNerd: does my problem has anything to do with the fact that we chose to shift by 32 instead of dividing by 2^32?
12:31 PM LeoNerd: doubt it. Those are the same operation
12:31 PM HelloShitty: I'm asking this because the original code I'm testing also shifts byte >> 1 on his code
12:31 PM LeoNerd: I'd be looking into endian issues
12:31 PM LeoNerd: Possibly your SPI-alike function is working backwards
12:31 PM HelloShitty: But how the original code works and mine doesn't?
12:31 PM HelloShitty: This is the original code I used to make my own
12:32 PM HelloShitty: http://dhlpilotcentral.com/arduino/ad9850_nr8o.ino
12:32 PM * LeoNerd has a general allergy to .ino files ;)
12:32 PM HelloShitty: it's just a code
12:32 PM LeoNerd: Yah; LSB-first
12:32 PM LeoNerd: that sounds fine
12:33 PM HelloShitty: but my code is doing the same, no?
12:33 PM LeoNerd: Yes; it's "code" but it strongly implies "arduino"
12:33 PM LeoNerd: which is where my allergy comes from ;)
12:33 PM HelloShitty: yeah, I know
12:33 PM HelloShitty: a lot of people related to AVR have those allegies
12:33 PM HelloShitty: xD
12:34 PM HelloShitty: Anyway, how come my code is not correct compared to that one?
12:34 PM LeoNerd: Yeah, dunno
12:34 PM LeoNerd: Have you identifed the difference yet?
12:34 PM LeoNerd: You'egv said it's not right, but how? What's the difference
12:34 PM HelloShitty: My code?
12:35 PM HelloShitty: I'm conffused now
12:35 PM HelloShitty: I think my code is excatly the same as that one on ino file
12:35 PM HelloShitty: The only difference, which is not a difference, is the way the frequency is calculated
12:36 PM LeoNerd: Nono, the difference between what your hardware is actually doing, vs. what you expected it would do
12:36 PM LeoNerd: What leads you to think it isn't quite working
12:36 PM HelloShitty: Because I was expecting to see the frequencies in my scope and they are not correct
12:37 PM HelloShitty: for intance in my code I sued 2Mhz
12:37 PM HelloShitty: then 5Mhz
12:37 PM HelloShitty: then 10 Mhz
12:37 PM HelloShitty: and finally 39Mhz
12:37 PM LeoNerd: Right
12:37 PM LeoNerd: So compare those
12:37 PM HelloShitty: and the scope doesn't sees any o fthese frequencies
12:37 PM LeoNerd: Sure
12:37 PM LeoNerd: give me details
12:37 PM LeoNerd: What's different?
12:37 PM LeoNerd: Are all the values double? or half?
12:37 PM LeoNerd: Or are they some fixed offset?
12:37 PM HelloShitty: ok, let me probe again to past ehere exact results
12:37 PM LeoNerd: Are they at least in the righht range difference?
12:38 PM LeoNerd: I.e. you get bigger numbers when you expected bigger numbers?
12:38 PM LeoNerd: Lots of things you can compare here
12:38 PM HelloShitty: that I think so
12:38 PM HelloShitty: I think the 2 outputs I have, they only double the other one
12:38 PM HelloShitty: like if in out1 I have 10 HZ, in out2 I'll have 20Hz
12:38 PM HelloShitty: and so on I guess
12:39 PM HelloShitty: But I'll only test out1
12:41 PM HelloShitty: 5 minutes and I'll be back with values
12:41 PM LeoNerd: Well I'll be off at dinner
12:41 PM LeoNerd: But good luck
12:41 PM HelloShitty: ok, thanks
12:47 PM ravon: Is Atmel Start any different from ASF?
12:52 PM HelloShitty: Ok, LeoNerd... When you come back, here are the values from scope:
12:52 PM HelloShitty: 1.7Khz, 4.24Khz, 8.67Khz and 33Khz
01:07 PM rue_house: what are ya trying to do?
01:29 PM LeoNerd: HelloShitty: that sounds like they're going up in the right direction just not the right number
01:30 PM LeoNerd: So I'd suspect your calculation
01:31 PM LeoNerd: Thwy all go up in the right ratios it seems
01:32 PM HelloShitty: yes, indeed LeoNerd
01:32 PM HelloShitty: Just can't figure out why is the error in calculation
01:33 PM HelloShitty: If I try to use 1Mhz or so, would that make it easy to spot the error?
01:35 PM LeoNerd: I'd start by seeing what the factor of error is
01:35 PM LeoNerd: it's not x10 or x100
01:35 PM LeoNerd: maybe it;s x256 or so? That might suggest something
01:36 PM HelloShitty: ok
01:36 PM HelloShitty: I get 1.7Khz when I sent 2Mhz
01:37 PM HelloShitty: dividing one by the other I get 1176.470
01:37 PM LeoNerd: Indeed... not a terribly+ pretty number. what of the others?
01:38 PM HelloShitty: the next one gives my about half of the previous one
01:38 PM HelloShitty: 576.701...
01:38 PM HelloShitty: the next one which was 10Mhz and I got 33Khz
01:38 PM HelloShitty: so the ratio is 303.030...
01:39 PM HelloShitty: wait
01:39 PM HelloShitty: Let me check the values again
01:39 PM HelloShitty: wait
01:39 PM HelloShitty: let me re-type values
01:40 PM HelloShitty: so for :
01:40 PM HelloShitty: 2Mhz, scopr read 1.7Khz - ratio of ~1176
01:41 PM HelloShitty: 5Mhz, scope read 4.24Khz - ratio of ~1179
01:41 PM LeoNerd: At this point I'd suggest working out manually, what numbers to set in the chip, and write those directly into the program
01:42 PM LeoNerd: to see if your chip-comm code is working
01:42 PM HelloShitty: 10Mhz, scope read 8.67Khz, ratio of 1153
01:42 PM HelloShitty: and finally
01:42 PM LeoNerd: mmm,.. sounds more systematic then yes
01:42 PM HelloShitty: 39Mhz, scope read 33Khz, ratio of 1181
01:43 PM HelloShitty: always around 1180 or so
01:44 PM HelloShitty: python console doesn't let me execute that expression you told me for the frequency
01:45 PM HelloShitty: it complains about unsupported operand for floats and ints
01:45 PM LeoNerd: yes well :p
01:45 PM HelloShitty: I did in the console
01:45 PM LeoNerd: try an actual calculator?
01:45 PM HelloShitty: (2e6*125e6)>>32
01:46 PM LeoNerd: I make that 58208
01:47 PM HelloShitty: yeah, me too
01:47 PM HelloShitty: but in the calculator I used the division by the 2^32
01:47 PM LeoNerd: Mhm
01:47 PM HelloShitty: I'm not sure I have a mode to perform bitshift operations
01:48 PM LeoNerd: it's the same, really :)
01:48 PM LeoNerd: try putting that number directly in the program, bypassing the calculation
01:48 PM LeoNerd: work out the other numbers and test those
01:50 PM HelloShitty: you're saying to replace 'freq' on line 30 of my ideone code by this 58208 value?
01:50 PM LeoNerd: Also silly thought: this is a dds generator. are you sure that's a calculation for the entire waveform frequency? and not, say, the step frequency of the generator
01:51 PM LeoNerd: if the waveform table had ~1180 steps that would explain it
01:54 PM HelloShitty: LeoNerd: I don't know the answer to that
01:54 PM HelloShitty: This was the site with the original code
01:54 PM HelloShitty: http://nr8o.dhlpilotcentral.com/?p=83
01:55 PM LeoNerd: Check datasheet then :)
01:55 PM LeoNerd: I'm on my phone at a bus stop so I can't easily see
01:58 PM HelloShitty: ok ok
02:00 PM HelloShitty: to get ~5Mhz I need to send the value 6000000000 LeoNerd
02:01 PM HelloShitty: And also had to change frequency data type to uint64_t
02:02 PM JanC is now known as Guest23196
02:02 PM JanC_ is now known as JanC
02:39 PM HelloShitty: LeoNerd: I got the error
02:40 PM HelloShitty: Line 20 here
02:40 PM HelloShitty: https://ideone.com/hGS05v
02:40 PM HelloShitty: was wrong
02:40 PM HelloShitty: I set you in error when I showed you my formula
02:40 PM HelloShitty: It was the other way around
02:41 PM HelloShitty: not dividing by 2^32 but dividing by 125e6
02:44 PM LeoNerd: Ah
04:11 PM bss36504: LeoNerd: Though, on line 28, how would that be optimized? Just because your denominator is constant doesnt mean the expression can get optimized when the numerator is a variable.
04:12 PM LeoNerd: "line 28"? You'll have to remind me the reference
04:12 PM LeoNerd: Ah I see
04:13 PM LeoNerd: Yes; line 28 is not a runtime division
04:13 PM bss36504: right, it's a large complex division on an 8 bit micro, which seems silly.
04:13 PM LeoNerd: Hint: a / B is equivalent to a * C if B*C == 1
04:13 PM LeoNerd: It's not a division!
04:13 PM LeoNerd: It's a multiplication
04:14 PM LeoNerd: If you divide by a compiletime constant on avr-gcc, it will not emit a division call
04:14 PM LeoNerd: It makes a *multiplciation* call by a different constant
04:14 PM bss36504: ah
04:14 PM LeoNerd: You just have to find some other constant, C, such that B*C == 1 *when taking into account truncation*
04:14 PM LeoNerd: Hint: it's a 32bit result
04:14 PM bss36504: TIL
04:14 PM LeoNerd: So you just have to find any C that makes B*C == (n * 1<<32) + 1
04:15 PM LeoNerd: for any integer n that you don't care
04:15 PM LeoNerd: gcc can always find such a C
04:18 PM LeoNerd: But yes in summary: don't be afraid of division by compiletime constants. only variables
04:18 PM polprog: unknow type name uint8_t
04:18 PM polprog: wat
04:18 PM polprog: what the hell
04:20 PM LeoNerd: <stdint.h>
04:20 PM polprog: odd i never had to include that
04:20 PM LeoNerd: Maybe something else included it for you
04:20 PM polprog: probably
04:28 PM polprog: heh, cool
04:28 PM polprog: gcc is indeed replacing it with mul
04:29 PM LeoNerd: Mhm :)
04:30 PM polprog: oh god
04:30 PM polprog: https://puu.sh/xgQKK/e9e8dec09c.png
04:31 PM polprog: it crated some kind of a function
04:31 PM LeoNerd: That's probably one of the multiply helpers
04:32 PM LeoNerd: I end up with about 6 of those of various kinds
04:32 PM polprog: i dont see it actually writing to PORTA
04:32 PM polprog: odd
04:49 PM polprog: i wonder if in some cases division by repeated substraction would be ok
04:49 PM polprog: probably not...
04:49 PM polprog: suppose i want to divide an 8 bit number by qp
04:50 PM polprog: s/qp/10
04:53 PM polprog: suppose i want to divide a variable by 10... so the constant would be 0.1 cos 10*0.1 == 1
04:53 PM polprog: but how would 0.1 be represented in assembly?
04:53 PM polprog: i dont get thay division by multiplication in this case
04:54 PM LeoNerd: Oh, divide by 10 is really easy
04:54 PM LeoNerd: It's a multiply and shift
04:55 PM polprog: i cant imagine that
04:56 PM polprog: mul by what and how many shifts
05:08 PM Emil: Gah
05:08 PM Emil: How do I make avr multiply two unsigned long long numbers together
05:08 PM Emil: I tried all sorts of trickery but the fucker optimises
05:18 PM Casper: 64 bits?
05:18 PM Casper: emil: *
07:16 PM enh: hi
07:46 PM Tom_itx is now known as Tom_L
08:44 PM Thrashbarg__ is now known as Thrashbarg
09:45 PM rue_shop3: how do you mean it optimizes?
11:41 PM day is now known as daey