#avr Logs

Mar 06 2018

#avr Calendar

12:37 AM polprog: good morning
12:40 AM * nuxil yawns and sips some coffee
12:40 AM nuxil: good morning
12:48 AM nohitzwork: morining
12:48 AM nuxil: whats up.
12:51 AM polprog: i got qemu working with gdb yesterday
12:51 AM polprog: can set breakpoints in my code now :)
12:51 AM nohitzwork: tired as fuck
12:51 AM nohitzwork: and should code
12:51 AM polprog: getting to school
12:51 AM polprog: tired as well
12:51 AM polprog: :(
12:51 AM * nuxil gives nohitzwork a cup of black coffee
12:51 AM nohitzwork: im drinking battery
12:51 AM nohitzwork: it helps a little
12:51 AM nuxil: i dont trink that stuff. battery, redbul, monster.
12:53 AM nuxil: i heard that monster and redbull has taurin or something in it. syntetic bullgall or seamen or something. not sure tho. havent inestigated it :p
12:58 AM nohitzwork: yeah its sgiut, i know that
12:58 AM nohitzwork: *shit
01:01 AM polprog: i never drank energetics
01:01 AM polprog: taurin is crap
01:02 AM polprog: its tea or coffee for me
01:02 AM nuxil: black coffee if im tierd.
01:04 AM polprog: time for our favourite subject
01:04 AM polprog: programming
01:04 AM nuxil: whats on the topic today ?
01:04 AM nuxil: the while loop ? :p
01:05 AM polprog: yes
01:05 AM nuxil: o.O
01:05 AM polprog: also, welcome to the computer lab
01:05 AM polprog: https://puu.sh/zBDT6/a8ab0e8081.jpg
01:05 AM nuxil: heh
01:05 AM polprog: rofl
01:06 AM polprog: i think thats the system disk...
01:07 AM polprog: told him to strike f1, it boted
01:07 AM nuxil: good old ide disks: :D
01:07 AM polprog: so looks like someone put the cdrw on pri slave...
01:15 AM polprog: i retired last ide-using computer in my bedroom on January
01:15 AM polprog: heh
01:23 AM nohitzwork: i got some coffee
01:23 AM nohitzwork: with cream and sugar
01:26 AM Casper: good for you? :D
08:12 AM McDonaldsWiFi: ATTiny's are freaking dope
08:12 AM McDonaldsWiFi: I've got this little thing running off of a shitty 6v 0.05w solar panel lol
08:12 AM nuxil: yes
08:13 AM McDonaldsWiFi: just gotta find a good use for it LOL
08:13 AM nuxil: dont smoke to many of them at once :p
08:13 AM McDonaldsWiFi: xD
08:13 AM Haohmaru: dig bitcoins! \o/
08:13 AM McDonaldsWiFi: lol 0.000000000000001 H/S
08:13 AM McDonaldsWiFi: prolly evne less :P
08:13 AM Haohmaru: hey, that's not == "nothing" then
08:13 AM McDonaldsWiFi: My niece has some cool light up shoes that stopped working, I thouht about tossing a tiny in there and making them do even cooler things
08:14 AM nuxil: which tiny are you messing with?
08:14 AM McDonaldsWiFi: 13a
08:14 AM nuxil: oki
08:14 AM Haohmaru: so stop complaining and start digging your way to becoming filthy rich!
08:14 AM McDonaldsWiFi: tbh I don't know much about avr chips yet... I just gabbed the first tiny's I saw on digikey
08:14 AM McDonaldsWiFi: xD
08:14 AM McDonaldsWiFi: I have like 0.25 monero laying around, am I rich yet? :P
08:14 AM nuxil: better off with atiny85 :p
08:14 AM McDonaldsWiFi: difference? memory cap?
08:14 AM nuxil: 13 got so little space
08:14 AM McDonaldsWiFi: 13 is pretty limited
08:15 AM McDonaldsWiFi: yeah but its power req are low af
08:15 AM nuxil: 1kb iirc
08:15 AM McDonaldsWiFi: I've had to knock it down to 1mhz~ for my shitty solar panel too lol
08:16 AM McDonaldsWiFi: I have some really good high quality cells
08:16 AM McDonaldsWiFi: but I don't have any glass so I'm afraid to use them xD
08:16 AM McDonaldsWiFi: a lot of good theya re in the box
08:17 AM nuxil: 300 μA is what you can run atiny85 at 1mhz with 1.8v. same for 13a?
08:17 AM nuxil: 0.1 μA at 1.8V in powerdown mode :)
08:18 AM Emil: nuxil: you can go even further beyond if iirc
08:19 AM McDonaldsWiFi: oh man you've changed my mind
08:19 AM McDonaldsWiFi: ill have to order some 85s lol
08:19 AM nuxil: :D
08:19 AM McDonaldsWiFi: also I just learned about the amazing world of watchdog timers
08:19 AM McDonaldsWiFi: how the hell did I not use sleep mode this whole time -.-
08:20 AM Haohmaru: there are xmegas for battery operation too ;P~
08:20 AM Haohmaru: "uber low power" ;P~
08:20 AM McDonaldsWiFi: what does the arduino mega use?
08:20 AM McDonaldsWiFi: for all those I/O?
08:20 AM nuxil: Emil, im sure its possible to tweek it some. dont he xmegas or some other chip go down to pico rane in sleep mode ?
08:20 AM McDonaldsWiFi: 2560?
08:21 AM nuxil: *range
08:21 AM Haohmaru: xmegas can switch clock sources so that's another vector you can play with
08:22 AM Haohmaru: ..i guess
08:22 AM nuxil: i belive most atmegas can that
08:22 AM Haohmaru: isn't it set via fuses there?
08:23 AM nuxil: Power-save Mode: 0.8/0.6μA (Including 32kHz RTC) thats in my atmega88/Atmega324 datasheet.
08:25 AM nuxil: idk about the fuse. never had use for it.
08:25 AM nuxil: i like my chips to spit out as many cycles as possible :p
08:26 AM Haohmaru: i don't think you can switch from internal to external crystal at runtime on the atmegas
08:26 AM Haohmaru: i could be wrong
08:27 AM nuxil: idk. as i said i never had use for a power saveing mode so i havent looked into it.
08:29 AM Haohmaru: neither have i
08:30 AM Haohmaru: "power-save power consumption @ vcc=3.0V == 1 to 3uA)" on the xmega A, and those are not optimized for battery usage
10:04 AM polprog: https://puu.sh/zBQHK/d3d4948d85.jpg
10:04 AM polprog: <3
10:06 AM Haohmaru: datasheety ;P~
10:07 AM Haohmaru: pls polprog, english
10:08 AM polprog: Haohmaru: what
10:08 AM polprog: :D
11:59 AM enh: Hi
12:00 PM tyzoid: hi
12:01 PM xoomas: hi
12:02 PM xoomas: who can help with uart? :)
12:02 PM Emil: I read: "who hurt you with uart" :D
12:02 PM Emil: xoomas: whatcha wanna know?
12:03 PM xoomas: how can i receive with atmega string
12:03 PM Tom_L: all of it
12:04 PM xoomas: i have RXCIE interrupt
12:04 PM Tom_L: http://tom-itx.no-ip.biz:81/~webpage/avr/atmega32/rs232_rx_test/
12:04 PM xoomas: i can easy acceps one byte
12:07 PM Tom_L: one byte at a time, and pretty soon the pie is all gone
12:09 PM xoomas: UCSRA=UCSRA|0x40;
12:10 PM xoomas: its transmite complete?
12:10 PM xoomas: do i need manualy set this bit>
12:12 PM Tom_L: short lunch, back to work..
12:12 PM Tom_L: later
12:13 PM cehteh: xoomas: the uart receives one byte at a time, in the interrupt you should save that somewhere else
12:16 PM xoomas: but like in this example maxbuffer size was sel also to 1
12:16 PM xoomas: but it can be bigger i guess
12:18 PM cehteh: i havent read you examples
12:18 PM Emil: xoomas: emil.fi/d/streamer.c
12:19 PM cehteh: we talked a few days ago about buffering/queues that is what you want
12:19 PM Emil: and here's a simplified version
12:19 PM Emil: https://emil.fi/d/seriallib.c
12:19 PM cehteh: in the simplest case your interrupt handler directly writes into some buffer until you see a \n or whatever you want as string end
12:19 PM xoomas: cahteh yeah i remeber
12:20 PM xoomas: i even watched youtube about ringbuffer
12:20 PM xoomas: until i knoked out ;D
12:20 PM cehteh: then you callback some line handler function (really recommended, not to do that from the ISR)
12:20 PM Emil: that serial"lib" above does ringbuffer
12:20 PM cehteh: i do something similar
12:21 PM xoomas: cehteh but till i have to do that in ISR
12:21 PM cehteh: small ringbuffer is fed from the ISR
12:21 PM xoomas: i mean to send every byte to ring buffer
12:21 PM polprog: i did the simple buffer approach
12:21 PM cehteh: and then for the 'user' code there is some buffer where data is appended (outside of isr)
12:22 PM cehteh: in the simplest case you can do some polling like thing, and your ISR of course needs to handle the buffer overflow condition somehow
12:23 PM xoomas: sucks that i have big wishes but small knowledge lD
12:23 PM xoomas: :D*
12:24 PM cehteh: isr pushes bytes to ringbuffer, you user--loop checks if there is data available, if yes (while(data_available)) it pushes these onto its own line buffer
12:24 PM cehteh: thats pretty easy to do and only needs a minimal ISR
12:24 PM polprog: my approach was easier
12:25 PM cehteh: as in ISR pushes directly to the line buffer?
12:26 PM cehteh: one can do that too, but that is a bit more timing critical
12:26 PM polprog: you have two buffers, ISR writes to one buffer, on command delimeter (CR), it copies the line buffer to the command buffer and sets a flag for the main loop
12:26 PM cehteh: ah that works too
12:26 PM cehteh: mine was only a simple suggestion (arduino like)
12:26 PM polprog: pobably could be done by swapping pointers, instead of strcpy now that i think about it but that project is frozen for the time being
12:27 PM xoomas: i dont use arduino :)
12:27 PM cehteh: in my mµos you register a callback function which gets called whenever a line is complete
12:27 PM xoomas: cehteh
12:27 PM cehteh: actually it comes with a full line editor including utf8 handling
12:27 PM xoomas: but this: "you user--loop checks if there is data available, if yes (while(data_available)) "
12:27 PM xoomas: if this is allways checking
12:28 PM xoomas: then its uses whole mcu time
12:28 PM polprog: wow
12:28 PM polprog: impressive
12:28 PM cehteh: yes thats polling, if course you do something else in the loop, only check once a while when nothing else is to do
12:29 PM cehteh: thats one possible/easy way to do it
12:29 PM xoomas: https://emil.fi/d/seriallib.c
12:29 PM cehteh: line editor and callbacks getting a bit more complicated and you can implement that later anyway, but first get the ringbuffer and small ISR's working
12:30 PM xoomas: but like that from this link is ok?
12:30 PM cehteh: Emils serial lib is a bit fragile, no error handling :D ... but yes thats the most simple way
12:31 PM xoomas: for now it will be ok :D
12:31 PM polprog: error handling: reset on error
12:31 PM xoomas: atleast need to get it running
12:31 PM cehteh: well when it bugs without you knowing why then you curse it :)
12:31 PM polprog: try { main(); } catch {}
12:31 PM cehteh: reset on error is ok too, but random overflow and crashing is not :)
12:32 PM polprog: in case of avr
12:32 PM polprog: i learnt that myself
12:32 PM polprog: ALWAYS free and always check if malloc returns not null
12:32 PM polprog: random reset ensues
12:32 PM polprog: :D
12:32 PM polprog: thats really in case of any C that uses dynamic memory...
12:33 PM xoomas: btw this ring buffer is 256 size?
12:33 PM polprog: why more
12:33 PM xoomas: no need more ;)
12:33 PM polprog: this is an 8 bit cpu
12:33 PM polprog: :D
12:33 PM polprog: go easy on it!
12:33 PM xoomas: i just want to learn :)
12:34 PM polprog: good!
12:34 PM cehteh: polprog: on embedded you rather never malloc and never free :D
12:34 PM cehteh: but when you really really need malloc, then dont free
12:35 PM polprog: cehteh: thats just a guideline :D
12:35 PM polprog: but that was only during init
12:35 PM cehteh: that fragments the little memory you have
12:36 PM polprog: i know
12:46 PM xoomas: also if more bytes received i guess it only adds to buffer
12:47 PM polprog: strlen or take a look at the index var
12:47 PM xoomas: so i have allways keep track of head and tail?
12:47 PM cehteh: actually you dont need to care (well the ringbuffer itself needs to handle that)
12:47 PM polprog: oh wait my bad
12:47 PM Emil: xoomas: on my implementation you only need to check the difference between the two indexes
12:48 PM cehteh: but from 'user' code side you only need to know if the ringbuffer has data available or is empty
12:48 PM Emil: yeah
12:48 PM cehteh: as long there is data you consume it (possibly checking for \n, in case you want to read line by line)
12:48 PM xoomas: but if lets say 10bytes arrived
12:48 PM cehteh: handle the line, clean up, rinse repleat
12:49 PM xoomas: so in user code i have to clean up ring buffer?
12:49 PM cehteh: no your user side line buffer
12:50 PM xoomas: then i have to copy from ring to line?
12:50 PM xoomas: sorry if too much questions :)
12:50 PM xoomas: this ring buffer is new to me :)
12:50 PM cehteh: the ringbuffer could be mostly opaque, you only need a data_available() and get_byte()
12:50 PM cehteh: for the 'user' side
12:50 PM xoomas: there is those 2
12:51 PM cehteh: and the isr only needs to push data (and psooibly check for overflows)
12:51 PM xoomas: but im not sure how i get data in user code
12:51 PM cehteh: so ISR() {push_byte(UDR);} ...
12:51 PM xoomas: yes
12:51 PM cehteh: and outside in your loop:
12:51 PM Emil: cehteh: you don't even exactly need data_available
12:52 PM Emil: you can bake it into get_byte :D
12:52 PM cehteh: i prefer functions which do single definitve things
12:52 PM Emil: cehteh: whatcha think about the posix read?
12:52 PM Emil: xoomas: you look at my "lib"
12:53 PM cehteh: char line[64]; int index=0; ....
12:53 PM Emil: xoomas: you see the three functions
12:53 PM Emil: you use two of them
12:53 PM xoomas: Emil yes im trying your code
12:53 PM Emil: xoomas: and you only need one of them really
12:53 PM Emil: xoomas: you still need to configure the uart peripheral
12:53 PM Emil: xoomas: look at the streamer.c I linked above
12:54 PM cehteh: while (data_available()) {line[index++]=get_byte(); if (line[index] == '\n') {woah, we got a line, handle it here, ....; index=0;} }
12:54 PM xoomas: uart works
12:54 PM xoomas: i only need to manage data ;)
12:54 PM Emil: and my code is only for m328p, realy
12:54 PM cehteh: xoomas: see ^^
12:54 PM Emil: streamer.c has an example that directly handles data
12:56 PM xoomas: thank you cehteh
12:56 PM Emil: the example above by cehteh works fine, also
12:56 PM Emil: requires polling though
12:56 PM xoomas: Emil yeah i seen streamer.c but for now its too much going on in that ISR :D
12:56 PM cehteh: yes, i already saiedm for simplicity start with polling, its not nice, but can later be changed to a callback
12:57 PM xoomas: somehow need to start ;)
12:57 PM cehteh: first make it simple and working, dont try tricks, write readable and somewhat verbose code
12:57 PM Emil: xoomas: in the ISR
12:57 PM cehteh: i think you can read and understand the example i gave above right away
12:57 PM Emil: if we got \n we have data so lets process that, else push the data to a buffer and reset the index if need be
12:57 PM xoomas: cehteh yes exactly :)
12:57 PM Emil: if we got data we do shit
12:58 PM xoomas: yes that line is understandable for me ;))
12:58 PM cehteh: actually you may check for \r and \n .. and just replace these with \0
12:58 PM cehteh: thats a bit more relaxing on different line ending conventions
12:59 PM xoomas: what im trying to make is eeprom programmer
12:59 PM cehteh: and when you get a \r\n telnet ending you handle an empty line which shouldnt harm
12:59 PM xoomas: i want to make pc side soft
12:59 PM xoomas: that sends commands to atmega
12:59 PM xoomas: and atmega does them :D
12:59 PM Emil: Then umm
12:59 PM cehteh: its completely up to you, how you parse the incoming data, i only assumed text in lines
01:00 PM Emil: I highly recommend having pretty much all abstractions and data handling on the pc side
01:00 PM xoomas: for now im only working with i2c eerpom
01:00 PM cehteh: yeah
01:00 PM Emil: unless you mean it to be used through a serial terminal
01:00 PM xoomas: no
01:00 PM cehteh: and if you can use text as protocol
01:00 PM xoomas: it will be all application
01:00 PM cehteh: line by line
01:00 PM Emil: then have the comms interface really simple and your avr really stupid
01:01 PM antto: this is what i put together for atmega: http://paste.debian.net/hidden/f1923a76
01:01 PM xoomas: i just need parse and configure what functions and what args to use in avr
01:01 PM Emil: literally only things I would have on avr side is: what device we are programming (what "driver to use") and write and read commands
01:02 PM Emil: write to address and read from address
01:02 PM Emil: nothing else avr side
01:02 PM xoomas: i have those 2 functions
01:02 PM xoomas: write address
01:02 PM xoomas: read address
01:02 PM xoomas: latter will implememt write page
01:02 PM xoomas: but for now its ok
01:02 PM xoomas: :)
01:03 PM xoomas: but on avr side need parser
01:03 PM xoomas: somehoe need to tell what to do :)
01:03 PM xoomas: but i guess its not very hard
01:04 PM xoomas: like there is 3 or 4 bytes commands
01:04 PM xoomas: <command><address><data><checksum> maybe
01:04 PM polprog: look at existing protocols
01:04 PM polprog: like MODBUS
01:06 PM xoomas: yes polprog something like that :)
01:08 PM polprog: :)
01:09 PM xoomas: ahh address should be more then one byte
01:09 PM xoomas: :))
01:09 PM polprog: id make it
01:09 PM polprog: [address][command][params][checksum]
01:10 PM polprog: so that not addressed devices can "drop out" first
01:10 PM xoomas: i seen like [id][len][command][data][crc]
01:11 PM polprog: mm
01:11 PM xoomas: but i guess i still need that ring buffer? :D
01:11 PM xoomas: anyhow i have to tryit anyway :D
01:12 PM xoomas: its clever buffer
01:14 PM polprog: try it, sire
01:14 PM polprog: sure*
01:14 PM polprog: thats the best way to learn
01:14 PM polprog: unless you want to be a theoretical elecronic engineer
01:14 PM polprog: then its just maths
01:14 PM polprog: :P
01:20 PM xoomas: :D
01:21 PM polprog: https://i.imgur.com/pe3ho0m.jpg
01:24 PM xoomas: :D
01:27 PM xoomas: hmm
01:28 PM xoomas: something im doing wrong :)
01:28 PM xoomas: why i think i need to take care of that ring buffer in 'my code'
01:29 PM xoomas: its like this ring is allways full :D
01:33 PM xoomas: line[index++]= serial_read();
01:33 PM xoomas: USART_Send(line[index]);
01:33 PM xoomas: im now trying this
01:34 PM xoomas: this is in while(data_available)
01:34 PM xoomas: i thought i have to get echo
01:34 PM xoomas: but i have like almost random data )
01:34 PM xoomas: but its not random :)
01:36 PM polprog: well, what is it then
01:38 PM xoomas: its like one time i send [1111] and i get 1234
01:38 PM xoomas: next time i send same 1111
01:38 PM xoomas: i et 1111
01:38 PM xoomas: again send 1111
01:38 PM xoomas: get 1234
01:38 PM xoomas: and it repeats ;)
01:46 PM xoomas: https://pastebin.com/jtV86hfY
01:46 PM xoomas: what im missing ;D
01:46 PM xoomas: line now im only getting same number of bytes that im sent
01:47 PM xoomas: only that there is 0x32 in them
01:48 PM xoomas: if i send lets say [U][U][U] i get [0x32][0x32][0x32]
01:48 PM xoomas: if i send more data i get same amount of 0x32
01:53 PM xoomas: any ideas? :)
01:57 PM xoomas: hmm
01:57 PM xoomas: line[index++]= serial_read();
01:57 PM xoomas: USART_Send(line[0]);
01:57 PM xoomas: if i do like that then i get echo
01:58 PM xoomas: but that means that im not filling buffer
01:59 PM xoomas: cehteh ?
02:02 PM xoomas: Emil maybe you still here? :)
02:15 PM cehteh: eh what? was afk
02:16 PM xoomas: cant get it working ;)
02:17 PM xoomas: cehteh here is pastebin https://pastebin.com/jtV86hfY
02:17 PM cehteh: that paste isnt complete and possibly racy
02:17 PM cehteh: you try to do too much at once, step by step, do you want to send data first or receive? make only one work for now
02:17 PM cehteh: make the ringbuffer work
02:18 PM cehteh: just as excercise: print "hello world" to the serial, wait 5 seconds, again
02:19 PM xoomas: i wanted to make echo to get feedback
02:19 PM xoomas: but i just send "hello world" many times without feedback
02:22 PM xoomas: https://pastebin.com/5Qhy96Uy
02:22 PM cehteh: ok, just verify that every step works
02:22 PM cehteh: when sending works, ok you can proceed
02:23 PM xoomas: https://i.imgur.com/GjFd8HQ.png
02:23 PM cehteh: now whenever you receive a byte, print a "x" (not echo)
02:23 PM cehteh: then try again if receiving works
02:24 PM xoomas: this was what i got ;)
02:24 PM cehteh: i dont know what hterm is and what that means
02:24 PM xoomas: it explains him self
02:24 PM xoomas: top is what i received
02:24 PM xoomas: bottom what i sent
02:25 PM xoomas: in blue ASCII
02:25 PM xoomas: in violet HEX
02:26 PM cehteh: so you send "hello world" and get "555..." echoed back?
02:26 PM xoomas: yes
02:27 PM cehteh: ok so now debug (aka think about) why thats the case
02:27 PM cehteh: prolly some race condition? missed some volatile declarations?
02:27 PM cehteh: all variables which are shared with ISR's and non ISR code need to be defined 'volatile'
02:27 PM xoomas: volatile unsigned char rxb[16], rxc=0, prxc=0;
02:28 PM cehteh: (but only those)
02:28 PM xoomas: only those are in ISR
02:28 PM cehteh: not all ISR vars, only the shared ones
02:28 PM cehteh: well for now ok .. doesnt do any harm except bad performance when you declare too much voltile
02:29 PM xoomas: :)
02:29 PM cehteh: next whenever you acces (get_byte() in my former example) data from a ringbuffer which is used by the ISR, you need to block ISR's for that time
02:30 PM cehteh: either cli/sei or just disable the uart intererupt for that time
02:30 PM xoomas: i can do cli()in isr
02:30 PM cehteh: not in the isr
02:30 PM xoomas: ahh
02:30 PM xoomas: so its fills that buffer still
02:30 PM cehteh: serial_read in your case
02:30 PM cehteh: otherwise you have some race condition
02:31 PM xoomas: im reading way too much times
02:31 PM xoomas: :))
02:31 PM xoomas: but now i set 5s delay
02:32 PM cehteh: dont fix things with delay
02:32 PM cehteh: serial_available() should just return false when there is nothing available and done
02:33 PM xoomas: but if check in while(1) loop
02:33 PM cehteh: that may already be racy, needs cli/sei as well to check on the queue
02:33 PM cehteh: yes, you can just while(1){if (serial_available()){...}; } insanely fast
02:33 PM cehteh: sure its somewhat malpractice to have such a busy loop
02:34 PM cehteh: *but* a delay is not the proper fix :)
02:34 PM xoomas: it just for now
02:34 PM cehteh: dont use delay there, just let it spin as fast as possible
02:34 PM xoomas: i just wanted to slow down that checking
02:34 PM xoomas: ok
02:34 PM cehteh: it must work that way, else you have some other bug and delays wont only hiding them
02:35 PM xoomas: i try now with if(available)
02:35 PM cehteh: aka serial_available() needs to block interrupts when it checks if there is anything in the queue
02:37 PM cehteh: ah sorry you can if(available) or while(available) .. the later might be the better choice in most cases, because then you can do some more workload in the loop, possibly receiving multiple bytes, and then handle them on the next iteration all at once
02:37 PM cehteh: batching similar work together has often better performance (as long you met any latency goals, but thats another story)
02:39 PM xoomas: hmm
02:39 PM xoomas: now not getting echo at all
02:40 PM xoomas: when stopin interrupts on check
02:40 PM cehteh: paste the code
02:41 PM xoomas: https://pastebin.com/hM9Pinfy
02:41 PM xoomas: i commented out ISR stop now :)
02:43 PM cehteh: serial_available() you need cli() before you check and sei() before return
02:44 PM cehteh: https://pastebin.com/FD6jN0u8
02:44 PM cehteh: and dont put () around return statments
02:44 PM cehteh: return is not a function
02:45 PM cehteh: err typo you spot it :D
02:45 PM xoomas: yes :)
02:45 PM xoomas: btw its Emil code :)
02:46 PM xoomas: but i can remove () :D
02:47 PM cehteh: i dont like that style, just minimally modified it to show you
02:47 PM xoomas: now it echos .. but not what i send
02:47 PM xoomas: it echo allways 0x00
02:48 PM cehteh: https://pastebin.com/d9Ma06tM is what i would use
02:48 PM cehteh: yeah
02:48 PM cehteh: step by step
02:48 PM cehteh: now you prolly have the same race on serial_read()
02:49 PM xoomas: but if i do:
02:49 PM xoomas: line[index++]= serial_read();
02:49 PM xoomas: USART_Send(line[0]);
02:49 PM xoomas: its echo perfectly
02:50 PM xoomas: its like index is not counting
02:50 PM xoomas: hmm need to check USART_Send(index)
02:51 PM xoomas: its allways 1
02:51 PM xoomas: how that can be :D
02:51 PM cehteh: i dont know what code you use for that
02:51 PM cehteh: i bet you have some races
02:51 PM cehteh: you have some buffer for sending too?
02:51 PM xoomas: i pastebin whole code ;)
02:52 PM cehteh: other way around than receiving
02:52 PM xoomas: that termH is i think with buffer
02:52 PM cehteh: user-code pushes bytes and the ISR consumes them one by one
02:52 PM xoomas: i mean i can write whole line
02:52 PM xoomas: and send it
02:53 PM xoomas: i send from terminal
02:54 PM cehteh: well i am off now, back tomorrow, just think about it and try not to fix to many things at once
02:55 PM xoomas: :D
02:55 PM xoomas: i bit confused now
02:55 PM xoomas: about what sending buffer :)
02:59 PM xoomas: i think it was bad idea to send data back when receivint it
03:03 PM xoomas: thats weird
03:03 PM xoomas: somehow that hello world get stuck in atmega ;D
03:15 PM xoomas: i still think that i have to clean ring buffer
03:53 PM Emil: hmm?
03:53 PM Emil: I'm always here
03:53 PM Emil: cehteh: also stfu btfo
03:53 PM Emil: return is a function fite me
04:18 PM polprog: niters
05:47 PM Ameisen: If I have basically no parts on hand, other than some mosfets not rated for 36VDC at gate, some diodes, and some resistors
05:47 PM Ameisen: is there any good way for the MCU to know that a 36VDC line is energized?
05:49 PM LeoNerd: Surely a potential divider, to bring it down to something at the MCU level?
06:31 PM Emil: The simplest way is often overlooked :D
06:47 PM Casper: Ameisen: 2 resistors
06:47 PM Casper: or
06:47 PM Casper: if you just want if the voltage is higher than about 2V, then a single resistor
06:48 PM Casper: atmel actually feed 240VAC (so 340V peak and more) via a 2M resistor directly to the pin
07:29 PM rue_: at 2M the diodes prolly take care of it ok
07:33 PM rue_: ohm -r 2000000 -v 336
07:33 PM rue_: Wattage is: 0.056448
07:33 PM rue_: Current is: 0.000168
07:33 PM rue_: Voltage is: 336.000000
07:33 PM rue_: Resistance is : 2000000.000000
07:33 PM rue_: so .17mA
07:34 PM rue_: I hope they put a small cap across it to make sure it didn't get surprized by transients
07:36 PM nuxil: 336v ?
07:36 PM rue_: peak of 240vac
07:36 PM nuxil: thats 339 :p
07:36 PM rue_: <Casper> atmel actually feed 240VAC (so 340V peak and more)
07:36 PM rue_: what value are you using for the square root of 2?
07:37 PM rue_: I'm using 1.4
07:37 PM nuxil: yea.
07:37 PM nuxil: anywho.. what are you guys talking about. atmel feeds 240 volt?
07:37 PM nuxil: i just woke up.
07:37 PM rue_: zlog
07:40 PM nuxil: what pin ? :p
07:40 PM rue_: digital input
07:43 PM nuxil: Oh also when did you guys start logging. i thoght we talked about this a while ago. and i can recall most of you guys disliked logging of the channel :p
07:43 PM rue_: its been logged since 2000
07:43 PM rue_: 18 years now
07:43 PM nuxil: o.O really
07:43 PM rue_: the wrong answers are available for any question you might have,
07:43 PM nuxil: haha :D
07:44 PM rue_: if you willing to go thru an infinite amount of trash to find it
07:44 PM nuxil: i'll pass :)
07:44 PM rue_: its ok, I'm going to write a bot that will go thru it and regurgitate facts
07:44 PM rue_: or what it thinks are
07:46 PM nuxil: write a bot like they have in ##C or C++ , a bot for noobs.. example: english sreg .spits out info for Status regiser so on.
07:49 PM rue_: hmm
07:50 PM rue_: I stopped buying arduino boards casue the stm32 baords are the same price
07:50 PM rue_: and now every time I go online to get an arduino I end up buying stm32
07:50 PM nuxil: heh
07:51 PM rue_: how the hell do you buy an 8 bit 16Mhz controller when a 72Mhz controller is the same price or cheaper?
07:51 PM nuxil: i got 1xstm32 board i havent used yet. nucleop
07:51 PM nuxil: *nucleo
07:51 PM rue_: I got a foundation for them, and wrote some stuff,
07:51 PM rue_: it was all good
07:51 PM rue_: but
07:52 PM rue_: https://www.aliexpress.com/item/STM32F103C8T6-ARM-STM32-Minimum-System-Development-Board-Module-For-Arduino-Micro-USB-controller-ARM-Learning-Board/32841974737.html
07:52 PM rue_: rrrrrr
07:53 PM nuxil: i like avr to much to mess around with my nucleo. i have no idea what to do with it.
07:54 PM rue_: well, if they are cheap enough, use tehm for the sam things the avrs are being used for
07:54 PM nuxil: i also have arduino board that i dont use. i dont know what to do whith these boards :p i like bare chips better :p
07:54 PM rue_: microchip is going to screw over the avr line, its just a matter of time
07:55 PM rue_: so, welcome to the world of using 72Mhz processors to flash leds
07:55 PM nuxil: :D
07:57 PM nuxil: also just the small stuff i seen about the stm. it looks like a mess compared to avr gcc toolchain. but i dont really know since i havent coded anything using the stm32 chips.
08:02 PM nuxil: i dont know how the tool chain for the stm's are but imo the avr-gcc is a pretty solid one and works great for avr's.
08:10 PM nuxil: rue_, https://www.aliexpress.com/item/STM32F103C8T6-ARM-STM32-Minimum-System-Development-Board-Module-For-Arduino-Micro-USB-controller-ARM-Learning-Board/32841974737.html
08:10 PM nuxil: how the hell is that possible.
08:11 PM nuxil: i mean. they must loose money. for less that 2 dollars, you get a small pcb dev board. including shipping.
08:12 PM nuxil: how can you make money on deals like that.
08:14 PM nuxil: i wounder if st is selling the chips with loss. to try take over the market for small mcu's avrs/pic so on....
08:18 PM chat is now known as Guest64523
10:10 PM rue_bed: I know eh?
10:11 PM rue_bed: it dosn't matter
10:11 PM rue_bed: cause microchip is going to screw up the avrs by changing the programming interface to all chips to somehting undocumented that is only provided by some programmer that they sell
10:12 PM rue_bed: its just a matter of time
10:15 PM nuxil: dont be so negative :p
10:45 PM Ameisen: mreh
10:45 PM Ameisen: Had my soldering station all ready
10:45 PM Ameisen: quadhands, holder, etc
10:46 PM Ameisen: broke because of insurance problems, and I need some optocouplers, resistors, and schottkys :(
10:48 PM rue_shop3: old electronics are free
10:48 PM rue_shop3: computer power supplies that have died have resistors and optos
10:48 PM rue_shop3: 7414 shottkey?
10:48 PM Casper: <rue_> what value are you using for the square root of 2?
10:48 PM rue_shop3: er, no wait
10:48 PM Casper: 1.4142
10:48 PM rue_shop3: yea, I used 1.4
10:48 PM rue_shop3: anyhow
10:49 PM rue_shop3: Ameisen, old computer power supplies have shottkeys in them too
10:49 PM rue_shop3: everything you need is in an old computer power supply
10:49 PM rue_shop3: if you knock on like 3 neighbours your likley to be given a computer they dont want anymore
10:49 PM rue_shop3: got the power supply you need parts from
10:54 PM nuxil: Casper, you know a trick to know if your calulator is a cheap ass one or not? just do a squar root(2) * squar root(2). if the result is not 2. its a cheap ass calulator :p
10:55 PM Casper: what if the cheap ass calc cheat?
10:56 PM nuxil: there are other tricks with other method aswell, google it :)
10:57 PM * Xark notes his cheap calculator is too cheap to have a square root... :)
10:57 PM Casper: what if it say 1.999999999999999999999 ?
10:58 PM nuxil: Casper, well. 1.9~ is not 2 :p
10:58 PM nuxil: anyway. if you need a poffesional calc to do engineering stuff. you dont go buy a 2$ calc :p
10:59 PM Casper: yeah
10:59 PM Ameisen: get the $3
10:59 PM nuxil: if will work fine for ohms law :p
10:59 PM Casper: and the 1.9~ is bc -l
10:59 PM Ameisen: or use an arduino or teensy and make your own
10:59 PM Xark: Casper: Not recommended for use with weapons grade materials or space agency projects. :)
11:00 PM Casper: maybe that's what north korea use? a cheap ass calculator? hence why the missiles goes boom?
11:00 PM rue_shop3: #include <math.h> int main(void){ printf("%f\n", sqrt(2)*sqrt(2)); return 0; }
11:01 PM rue_shop3: root@blackie2:/tmp# ./a.out
11:01 PM rue_shop3: 2.000000
11:01 PM rue_shop3: foof!, thats good!
11:02 PM nuxil: :D
11:02 PM Ameisen: now c++
11:02 PM rue_shop3: its an intel, I was worried
11:02 PM Ameisen: #include <cmath> int main() { printf("%f\n", sqrt(2.0f) * sqrt(2.0f)); }
11:02 PM Ameisen: about the same.
11:02 PM Casper: I wonder if those 2 are valid
11:03 PM Casper: I suspect that gcc might actually try to reduce that
11:03 PM Ameisen: with fastmath.
11:03 PM Ameisen: if you specify strict, it won't
11:03 PM Casper: and actually just kill the formula
11:03 PM rue_shop3: gcc test.c -lm ?
11:03 PM Ameisen: in C++, cmath isn't constexpr
11:03 PM Ameisen: so g++ generally won't reduce it
11:04 PM rue_shop3: to see the assembler...
11:04 PM Ameisen: soooomeday maybe they will add proper math library to stdlib. Instead they're making a graphics lib that nobody wants.
11:04 PM nuxil: lol
11:05 PM rue_shop3: gcc -S
11:06 PM rue_shop3: yes I think it optimized it out
11:07 PM Ameisen: #include <cmath> int main() { volatile float f = 2.0f; printf("%f\n", sqrt(f) * sqrt(f)); }
11:07 PM Ameisen: try that
11:08 PM rue_shop3: oh yea
11:08 PM rue_shop3: but the answer is still 2.00000
11:08 PM rue_shop3: :)
11:09 PM rue_shop3: "%12.0f\n"
11:09 PM rue_shop3: er
11:09 PM rue_shop3: root@blackie2:/tmp# ./a.out
11:09 PM rue_shop3: 1.999999931543
11:09 PM rue_shop3: now what
11:09 PM rue_shop3: 12.12
11:09 PM rue_shop3: cheapass right?
11:09 PM Ameisen: we're doomed
11:09 PM Ameisen: though, to be fair
11:09 PM Ameisen: we did request it to be done with floats
11:10 PM rue_shop3: double
11:10 PM Ameisen: unfortunately, the language doesn't define a native fixed-point type
11:10 PM rue_shop3: root@blackie2:/tmp# ./a.out
11:10 PM rue_shop3: 2.000000000000
11:10 PM Ameisen: gcc has one kinda, g++ doesn't
11:10 PM rue_shop3: with double
11:10 PM Ameisen: double is prolly rounding up
11:10 PM Ameisen: do a bunch of sqrts, nested
11:10 PM Ameisen: then multiple them against one another
11:10 PM rue_shop3: printf("%5.20f\n"
11:10 PM rue_shop3: ..
11:11 PM rue_shop3: root@blackie2:/tmp# ./a.out
11:11 PM rue_shop3: 2.00000000000000044409
11:11 PM rue_shop3: yes
11:29 PM day__ is now known as day