#avr Logs

Sep 15 2018

#avr Calendar

12:43 AM [1]MrMobius is now known as MrMobius
01:48 AM rue_mohr: anyone ever done serial at 230400 baud?
01:51 AM rue_mohr: http://wormfood.net/avrbaudcalc.php
01:52 AM rue_mohr: wtf
01:54 AM rue_mohr: damnit
01:54 AM rue_mohr: wormfooood!!!!!!!
01:57 AM rue_mohr: ok, well, I dont really even know if an avr can shovel data that fast anyhow
02:10 AM polprog: thats 200k, iirc, at 16MHz avr can easily do 2M
02:10 AM polprog: unless you forgot a zero there, cos thats a speed i dont recall
02:12 AM polprog: "easily".. ok. can do 2M but not that easily
10:53 AM rue_mohr: well, 230.4k would keep up with the adc
10:53 AM rue_mohr: if I'm sane, I could down that a little
10:54 AM rue_mohr: different angle
10:55 AM rue_mohr: according to my notes, I'm updating at 1.2Khz
10:55 AM rue_mohr: 16 bits...
10:55 AM rue_mohr: 2.4Kbytes/sec
10:55 AM rue_mohr: 24Kbits
10:56 AM rue_mohr: 38400 should work fine then, hmm
10:57 AM rue_mohr: I wonder how the best way to time it all out would be
10:57 AM rue_mohr: oh I blew that calc
10:57 AM rue_mohr: 8 axies @ 1.2Khz
10:58 AM rue_mohr: 16 bits X 8 @1200/sec
10:58 AM rue_mohr: ok, well 2 bytes * 8 @ 1200/sec
10:59 AM rue_mohr: so 8 bytes 2400/sec
11:00 AM rue_mohr: so so 1 byte 19200/sec
11:00 AM rue_mohr: so 192000 buad
11:00 AM rue_mohr: 200kbaud
11:07 AM steethdurvey: hello. i'm having a peculiar issue and cannot seem to find the right search recipe.
11:07 AM steethdurvey: i have a 32u4 exhibiting the following symptoms: opening Serial1 standard (8n1), data is sent correctly, but received data comes in garbled, predictably, in a repeatable manner
11:07 AM steethdurvey: opening serial1 with 7n1, data sent is received garbled, but data received from a sender with 8n1 settings, is received clearly.
11:07 AM steethdurvey: so it seems my chip is using an asymmetric number of data bits for tx/rx, and i surmise this is the kind of thing that can only be caused by software
11:07 AM steethdurvey: the hardware is an adafruit itsybitsy 32u4, 8MHz, 3.3v. the compiler is arduino v1.8.5
11:07 AM steethdurvey: i have independently confirmed this behavior using both an FTDI USB-serial and esp8266 as the device being communicated to
11:11 AM rue_mohr: ?
11:12 AM rue_mohr: are you sure your clock rate isn't just out?
11:12 AM rue_mohr: is this for usb or for plain serial?
11:12 AM rue_mohr: steethdurvey,
11:13 AM rue_mohr: <timeout>
11:13 AM steethdurvey: this is for serial
11:13 AM rue_mohr: ok, have it repeatedly send the character 'U' and see what you recieve
11:13 AM steethdurvey: i have used a third device to snoop the signals exchanged between a directly connected 32u4 -> esp8266
11:14 AM rue_mohr: ok, have it repeatedly send the character 'U' and see what you recieve
11:14 AM rue_mohr: U is special
11:14 AM rue_mohr: just repeatedly send the character U and see if its transferred correctly between the two ends
11:14 AM rue_mohr: U is 01010101
11:14 AM steethdurvey: weird.
11:15 AM rue_mohr: so, by what you actaully get, you can tell whats going wrong
11:15 AM rue_mohr: it sounds like a slight baud rate error
11:17 AM steethdurvey: rue_mohr: https://pastebin.com/zTjMkC7P
11:17 AM rue_mohr: the watchdog is another thing that causes errors for people who aren't paying attention
11:17 AM steethdurvey: rue_mohr: but data sent in the other direction works fine, and if I set the 32u4 to 7n1, data is received fine
11:18 AM rue_mohr: maybe your serial init code is wrong
11:18 AM rue_mohr: show us what you did to init the serial on the avr
11:19 AM rue_mohr: it does almost sound like a 7/8 bit mismatch
11:19 AM rue_mohr: you CAN set the avr to send and recieve in different bit lengths iirc
11:20 AM rue_mohr: but your adapter can only send int eh same
11:20 AM rue_mohr: U working means your baud rate is right
11:20 AM rue_mohr: which leaves, bits, stop-bit-count, and parity-bit-count
11:22 AM steethdurvey: rue_mohr: i am using arduino so it is Serial1.begin(115200);
11:22 AM rue_mohr: ok, DONT use 115200
11:23 AM rue_mohr: cause at 8Mhz, the avr cant properly generate that speed
11:23 AM rue_mohr: use 9600 for testing
11:23 AM rue_mohr: 19200 can also be generated correctly iirc
11:23 AM steethdurvey: rue_mohr: if i modify it to Serial1.begin(115200, SERIAL_7N1); then the data is read correctly, but appears garbled in the opposite direction
11:23 AM rue_mohr: https://cache.amobbs.com/bbs_upload782111/files_22/ourdev_508497.html
11:23 AM rue_mohr: ok, DONT use 115200
11:23 AM rue_mohr: use 9600 for testing
11:23 AM steethdurvey: rue_mohr: the esp8266 is fixed to 115200. i was trying to use the 32u4 as a programmer passthrough when i encountered the problem
11:24 AM rue_mohr: https://cache.amobbs.com/bbs_upload782111/files_22/ourdev_508497.html
11:24 AM steethdurvey: but considering i'm about to desolder everything...
11:24 AM rue_mohr: ^^^^ open that link
11:24 AM rue_mohr: ^^^^ open that link
11:24 AM rue_mohr: ^^^^ open that link
11:24 AM rue_mohr: ^^^^ open that link
11:24 AM rue_mohr: look at the 8Mhz table
11:24 AM rue_mohr: see how 2400 thru 19200 are green?
11:24 AM steethdurvey: i see.
11:24 AM rue_mohr: those rates are generated correctly with an 8Mhz clock
11:24 AM steethdurvey: interesting indeed.
11:24 AM rue_mohr: and 38400
11:25 AM rue_mohr: see how there is a 7.8% error with 115200?
11:25 AM steethdurvey: so, in other words, don't use a 32u4 to pass through program an esp8266 :x
11:25 AM rue_mohr: no
11:25 AM steethdurvey: rue_mohr: any idea why the problem is asymmetric?
11:25 AM rue_mohr: dont try to crank the baud as fast as you can on any random peice of hardware
11:25 AM rue_mohr: it will do 38400 find
11:25 AM rue_mohr: fine
11:26 AM rue_mohr: unless you run that M32u4 at a different speed, you cnt do 115200 properly
11:26 AM rue_mohr: consider running it at 11.0592Mhz
11:26 AM steethdurvey: yeah, i'm not going to get out of patching in to program the esp8266 am I
11:26 AM rue_mohr: the asymmetry is because of the different timing correction systems
11:27 AM rue_mohr: run it all slower, it'll still be done in the time it takes you to crack your knuckles
11:27 AM rue_mohr: 38400 for the win
11:28 AM steethdurvey: okay. i guess i thought, 115200 no harm done. i stand corrected
11:29 AM rue_mohr: unless the code is small that processes the characters, the avr prolly cant keep up with 115200 anyhow
11:29 AM rue_mohr: unless the character transmissions are spaced out
11:30 AM rue_mohr: *just because it can receive a chacater at that speed, dosnt' mean it can receive a stream at that speed
11:30 AM rue_mohr: http://wormfood.net/avrbaudcalc.php is wormfoods site still down!?
11:30 AM rue_mohr: awe
11:31 AM steethdurvey: rue_mohr: since it's arduino my options for changing baud are avrdude command line parameters
11:32 AM rue_mohr: apparently it was there mar9?
11:32 AM rue_mohr: change your arduino code
11:32 AM rue_mohr: init the serial to 38400 instead of 115200
11:33 AM steethdurvey: rue_mohr: the problem remains that i'm talking to an esp8266, which is programmed at 115200
11:33 AM steethdurvey: how did this ever work
11:33 AM steethdurvey: maybe i should find a heat source
11:33 AM steethdurvey: because i'm pretty sure this used to work
11:33 AM rue_mohr: 7.8% error
11:34 AM rue_mohr: so every 8/100 bits would probably be wrong
11:41 AM steethdurvey: rue_mohr: looks like this board has a fixed external osc, so looks like i have some work to do.
11:51 AM steethdurvey: reprogramming the esp was less hard than i thought, even with it wired into this system. just held the 32u4 from initializing the serial so i could use a separate serial adapter
11:51 AM steethdurvey: turns out it can be programmed at 38400 too
11:55 AM steethdurvey: rue_mohr: confirmed working. Thanks again
11:56 AM MarcinWieczorek_ is now known as MarcinWieczorek
11:21 PM day__ is now known as day