#avr Logs

Nov 29 2017

#avr Calendar

01:03 AM ElementalWarrior: I'm having an issue with usb descriptors on an atmega16u2, I'm trying to use 3 interfaces, control + two audio
01:06 AM ElementalWarrior: when I increment bNumberInterfaces from 2 to 3 in the configuration descriptor, the device no longer enumerates
01:06 AM ElementalWarrior: if I run the USB Viewer tool on windows, it isn't even presenting descriptors anymore
01:06 AM ElementalWarrior: anyone have any ideas?
01:08 AM _ami_: control interface?
01:09 AM ElementalWarrior: what about the control interface?
01:09 AM _ami_: ElementalWarrior, i think you don't need control interface as far as i know. its generally implemented by usb framework.
01:09 AM ElementalWarrior: it's required for usb audio
01:09 AM _ami_: then its not control EP
01:10 AM _ami_: it might be other EP (not control EP)
01:11 AM ElementalWarrior: for audio the control interface is required to describe the input and output terminals
01:11 AM ElementalWarrior: the device enumerates fine with 2 interfaces, one of which is the control interface
01:13 AM _ami_: thats weird. generally usb framework implements control EP (in/out) by default and you have a control_ep_callback where you take actions on control EP.
01:13 AM _ami_: which library are you using for this?
01:13 AM ElementalWarrior: LUFA
01:13 AM _ami_: whats the EP address you have for your control EP?
01:14 AM _ami_: should be zero IMO
01:14 AM ElementalWarrior: 0
01:14 AM _ami_: hrm
01:15 AM ElementalWarrior: whats really odd to me is that I can use the VirtualSerialMouse example from LUFA, which has 3 interfaces, and works fine :S
01:15 AM _ami_: LUFA is weird ~
01:16 AM _ami_: did not like this library.
01:16 AM ElementalWarrior: the annoying thing is when it fails with 3 interfaces, it no longer reads the descriptors in usbview.exe
01:19 AM ElementalWarrior: which is what tells me what the final descriptors are, and any errors
01:19 AM _ami_: so it stopped working when you add control ep interface?
01:19 AM ElementalWarrior: although I just tried removing one of the interfaces in the working example, and its doing the same thing, so maybe I have my interfaces setup wrong
01:19 AM ElementalWarrior: nono
01:19 AM ElementalWarrior: It stops working when I add another audio interfaces
01:19 AM ElementalWarrior: interface*
01:19 AM ElementalWarrior: I started with 1, need 2
01:19 AM _ami_: aha
01:19 AM ElementalWarrior: 3 total with control interface
01:19 AM _ami_: got it.
01:19 AM _ami_: how many EPs are required for a usb audio interface?
01:19 AM _ami_: i think you might need associate them
01:21 AM _ami_: ElementalWarrior, which device class you gave at device_desc header struct?
01:21 AM _ami_: you might need to set it to USB_MISC_CLASS
01:22 AM ElementalWarrior: right now I'm using an IAD class, the example uses a USB_CSCP_NoDeviceClass
01:23 AM _ami_: or you can defined classes at interface level by setting class type to 0 at device_desc
01:24 AM ElementalWarrior: yeah thats what NoDeviceClass does I Think
01:25 AM _ami_: did u set the bInterfaceNumber correctly?
01:26 AM ElementalWarrior: yeah it was 2, then 3 when trying to use 3 interfaces
01:26 AM _ami_: 0, 1, 2 -> that should be number
01:26 AM _ami_: for indexes
01:26 AM ElementalWarrior: and added another byte after the first interface to recognize it
01:27 AM ElementalWarrior: yep
01:27 AM _ami_: hrm
01:27 AM _ami_: i will paste my example but its for stm32f103/libopencm3
01:27 AM _ami_: and its heavily based on my own library over libopencm3
01:28 AM ElementalWarrior: alright, the descriptors for lufa are just structs, basically just names to numbers aha
01:28 AM _ami_: ElementalWarrior, https://pastebin.com/QKv7Y093
01:29 AM _ami_: its a usbdevice with usbaudio + vendor class
01:30 AM _ami_: i remember now, usbaudio requires 2 bulk eps for in/out
01:30 AM _ami_: ElementalWarrior, worked now?
01:30 AM _ami_: so what was the mistake?
01:31 AM ElementalWarrior: no I'm still mucking with it
01:31 AM _ami_: i wrote my own usb wrapper to avoid filling stupid headers all the time. :/
01:31 AM ElementalWarrior: you mean endpoints or terminals?
01:33 AM _ami_: show me your config_desc struct
01:33 AM _ami_: i hope you set the no. of interfaces to 3 there.
01:33 AM ElementalWarrior: Config = { .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), .TotalInterfaces = 3, .ConfigurationNumber = 1, .ConfigurationStrIndex = NO_DESCRIPTOR, .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED), .MaxPowerConsumptio
01:33 AM ElementalWarrior: well thats not helpful
01:33 AM ElementalWarrior: https://pastebin.com/fiA5cE3y
01:35 AM ElementalWarrior: heres the whole thing, I've been changing values to try to get it to at least spit out descriptors in usbview.exe, so there may be some things that dont quite line up, like terminal numbers etc
01:35 AM ElementalWarrior: https://pastebin.com/m1tbmUkA
01:37 AM ElementalWarrior: also I've been commenting and uncommenting blocks as well aha
01:37 AM ElementalWarrior: so its kinda of a mess of me trying a million different iterations
01:38 AM _ami_: ElementalWarrior, config.wTotalLength -> where is this in your code?
01:38 AM ElementalWarrior: descriptors.c
01:38 AM _ami_: does it filled by LUFA automatically?
01:39 AM _ami_: AFAIK, This should hold the total size of the configuration descriptor
01:39 AM _ami_: including all sub interfaces
01:39 AM _ami_: in my case, libopencm3 fills it automatically for me.
01:39 AM ElementalWarrior: LUFA defines the structs and the constants, and handles the sizes of things
01:39 AM _ami_: aha
01:39 AM _ami_: ok
01:40 AM Thrashbarg_ is now known as Thrashbarg
01:47 AM _ami_: abcminiuser could help you. he is the LUFA author.
01:48 AM ElementalWarrior: aha I asked him on twitter, pointed me to memory size and max number of endpoints on the atmega16u2, which I Should be fine for both
01:50 AM _ami_: ok
01:51 AM _ami_: ElementalWarrior, i have implemented multiserial on stm32f103 and it worked fine. one CDC-ACM requires 3 EPs so for 2 CDC-ACMs, total 6 EPs are used.
01:51 AM _ami_: https://pbs.twimg.com/media/DK0hXsYVYAA7ySo.jpg
01:56 AM ElementalWarrior: so wait it needs 2 endpoints for each audio interface?
01:56 AM ElementalWarrior: why would that be?
01:56 AM _ami_: yes
01:56 AM _ami_: its the generic implementation. if you want your device to work without driver.
01:57 AM _ami_: HID usb audio
01:58 AM ElementalWarrior: I'm using the standard windows drivers
01:58 AM ElementalWarrior: have a link I could read?
01:58 AM _ami_: that also comes under HID audio class.
01:58 AM _ami_: https://www.silabs.com/documents/public/application-notes/AN295.pdf
01:59 AM _ami_: https://www.edn.com/design/consumer/4376143/Fundamentals-of-USB-Audio
01:59 AM _ami_: you need basically 4 "(including control ep)
02:00 AM _ami_: Interrupt one also
02:00 AM ElementalWarrior: the interrupt is not required
02:00 AM _ami_: is it optional?
02:00 AM ElementalWarrior: yeah thats what the audio doc said
02:00 AM _ami_: https://www.edn.com/design/consumer/4376143/Fundamentals-of-USB-Audio
02:00 AM _ami_: ok,
02:01 AM ElementalWarrior: in the atmega16u2 datasheet it has 5 endpoints
02:01 AM ElementalWarrior: USB 2.0 Full-speed device • Ping-pong mode (dual bank), with transparent switch • 176 bytes of DPRAM – 1 endpoint of 64 bytes max (default control endpoint) – 2 endpoints of 64 bytes max (one bank) – 2 endpoints of 64 bytes max (one or two banks)
02:01 AM ElementalWarrior: grrr formatting
02:01 AM ElementalWarrior: https://pastebin.com/Rte210AX
02:03 AM ElementalWarrior: so shouldnt I need 3 endpoints then?
02:04 AM _ami_: i think you need to fill usb_audio_headers too?
02:05 AM _ami_: usb midi example: https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f4/stm32f4-discovery/usb_midi/usbmidi.c
02:07 AM ElementalWarrior: you're talking the descriptors now or endpoints?
02:07 AM _ami_: descriptors
02:07 AM ElementalWarrior: yeah thats the audio control interface, I have that filled out
02:09 AM _ami_: it says that you need ISOCHRONOUS EPs for DATA in/out.
02:09 AM _ami_: but i think bulk EPs will also work.
02:09 AM _ami_: got linux PCs/laptop?
02:09 AM _ami_: try plugging your device? and check the output at dmesg -wH
02:10 AM _ami_: usb host kernel framework will spit out something useful which can help you in debugging
02:13 AM ElementalWarrior: I think I have a dual boot on this thing, or I can probably use a VM
02:13 AM _ami_: i shall try hid usb device on stm32f103 today or during weekend.
02:14 AM _ami_: have not done much on audio.
02:14 AM * _ami_ lacks understanding of physics behind audio
02:14 AM _ami_: wanted to start from generating audio to making a audio device.
02:15 AM _ami_: but no time.
02:15 AM ElementalWarrior: aha, I somewhat understand, my hardware development understanding is quite limited though aha
02:18 AM ElementalWarrior: for dmesg do I need to plug in the usb at boot?
02:18 AM _ami_: no
02:18 AM ElementalWarrior: well the vm way isnt working then aha
02:18 AM _ami_: first start dmesg -wH on terminal
02:18 AM _ami_: and then plug the device.
02:18 AM ElementalWarrior: yeah I did, just not showing up
02:18 AM _ami_: damn
02:22 AM ElementalWarrior: 'll boot into my linux partition
02:22 AM ElementalWarrior: gimme a bit I'll be back
02:26 AM qwebirc230451: it's saying unit 0 not found aha
02:28 AM qwebirc230451: hmm
02:29 AM ElementalWarrior: it's saying unit 0 not found
02:29 AM ElementalWarrior: I have to go get the toolchain for linux now aha
07:18 AM nuxil: omg. i need to stop useing Firefox. its had become a crapy memory hugger, and bloatware. i got 3 tabs up.. 1, fb. 2, hotmail. 3. youturbe. and for this it needs 6 seperate prosesses and consumes over 2GB of ram. :(
07:18 AM Thrashbarg: fb is the culprit
07:19 AM nuxil: yea. i know fb uses alot. esp if the chat is on.
07:19 AM Thrashbarg: I will allot you some memory then
07:21 AM nuxil: just did same tabs in chrome. 450MB it uses.
07:21 AM * nuxil tosses Firefox into the bin
07:26 AM thardin: is this the newest firefox? seems pretty fast to me
07:26 AM thardin: real problem is still using fb and yt
07:26 AM thardin: who does that even?
07:27 AM nuxil: thardin, i belive it was 57.
07:27 AM thardin: 57 is what I have. no issues
07:30 AM nuxil: but why does FF use like 4x more mem than chrome,
07:30 AM polprog: firefox has got better for me recently
07:30 AM Thrashbarg: there's supposed to be a new release that fixes a lot of memory issues
07:31 AM Thrashbarg: I wouldn't know. Debian
07:31 AM nuxil: i test with loading same url's in both browsers. fb, yt + playing muted, and hotmauk.
07:31 AM nuxil: *hotmail
07:31 AM nuxil: ff used over 2gb.
07:31 AM nuxil: makes no sense :p
07:31 AM thardin: welcome to the modern web
07:32 AM polprog: my site definitely wont take that much
07:32 AM polprog: the most heavy content is the ttf file
07:32 AM nuxil: yea it suckes. its a huge mess. html, php, js, java, json, ajax, css +++
07:32 AM nuxil: a huge mess :p
07:32 AM polprog: lel
07:32 AM polprog: gotta go, lesson started
07:33 AM Thrashbarg: I have a suspicion the WWW would've been easier to program for and faster if they just went with a turing machine instead of JS
07:34 AM cehteh: forth ftw
07:34 AM Thrashbarg: :D
07:34 AM nuxil: i heard of turning machines. but i though it was only a teory. dont really know what it is
07:35 AM Thrashbarg: they're the most logically simple machine that can calculate any mathematical problem. They're also known as Turing Tar Pits because they're just about impossible to program correctly by hand
07:35 AM Thrashbarg: impossible/needlessly difficult
07:35 AM thardin: that doesn't really change much
07:35 AM Thrashbarg: my point :P
07:35 AM nuxil: lol
07:35 AM thardin: the web could have been built on postscript
07:35 AM thardin: in fact that would have been rather neat
07:36 AM Thrashbarg: yeah
07:36 AM thardin: could've done that with the alto
07:38 AM nuxil: the web model needs to be redefined, and put into one language. not mix in all this crap as we do today.
07:38 AM nuxil: if you like spaghetti programming.. do web stuff :p
07:39 AM Thrashbarg: lasagna code too
07:39 AM nuxil: :)
07:41 AM thardin: I might not be so negative about all the js if it weren't also for all the tracking and all the lock-in
07:41 AM thardin: agpl all the things
07:47 AM Thrashbarg: needs more integers
12:50 PM nuxil: i have become hooked on 8bit chiptune music..
12:51 PM nuxil: man to much 8 bit around my head atm. 8bit controller, 8 bit music.
12:51 PM nuxil: its like im back in the 80's :p
12:51 PM cehteh: lol
12:52 PM nuxil: this rakohus dude is good at doing covers and make them 8bit sound from scratch
12:53 PM nuxil: https://www.youtube.com/watch?v=U4IXJo9gXvQ&index=2&list=PL877PlM_9HNYSqF_-CvR80UHJVUEUfgcc
12:53 PM * cehteh listens to 16bitfm :D
12:58 PM cehteh: https://www.youtube.com/watch?v=RSmKPNp4Amk that one was awesome for the time
01:00 PM cehteh: https://www.youtube.com/watch?v=xcOkQKeDigs
01:16 PM fooman2011: Hello. I'm trying to use UART on my ATTiny2313A (datasheet:http://www.atmel.com/images/doc8246.pdf). I'm using this code: https://pastebin.com/qeUFTSRQ it works at 9600 bauds but doesn't work at 115200 bauds. The clock speed of my ATTiny2313A is 1Mhz. Could you please tell me what is wrong ?
01:17 PM nuxil: my guess is the slow clockspeed :p
01:17 PM fooman2011: I have tried at 8Mhz
01:17 PM fooman2011: same pb
01:18 PM nuxil: are you using the internal rc ?
01:18 PM fooman2011: rc is clock ?
01:18 PM fooman2011: internal clock
01:18 PM nuxil: ye
01:19 PM fooman2011: i'm using the internal clock yes
01:19 PM nuxil: that could be it. idk. the experts will know :p
01:20 PM fooman2011: I should use an external clock ?
01:20 PM nuxil: afik the internal rc is not good at keeping things in sync. it can slew off a bit.
01:20 PM nuxil: but i might be wrong
01:21 PM nuxil: well it dosent hurt to add a crystal. its far superior to the internal rc
01:22 PM nuxil: but hear with cehteh, Emil, polprog etc. im sure they know. im still a noob
01:23 PM nohitzzz: i made a dubstep song with SID chip https://soundcloud.com/no-hit-wonder/shotgun-snare
01:23 PM nohitzzz: SID-step
01:23 PM nuxil: sid?
01:24 PM nohitzzz: c64's sound chip
01:24 PM nuxil: ah ;)
01:43 PM nohitzzz: nuxil if you wanna combine chip music and electronics/avr, make a SID synth
01:44 PM nohitzzz: here's the datasheet http://www.waitingforfriday.com/?p=661
01:44 PM nuxil: :)
01:48 PM pwillard: Internal Clock and Serial I/O... Hang on... must... keep... straight... face...
01:49 PM cehteh: works .. but you may need to calibrate it
01:50 PM cehteh: fooman2011: how do you use the UART? interrupt driven?
01:50 PM cehteh: ah no ..
01:52 PM cehteh: fooman2011: some frequencies you can reach with normal dividers and standard frequencies are a bit off, plus the nominal speed from internal RC isnt pretty accurate
01:53 PM pwillard: hence my comment
01:53 PM cehteh: yes
01:54 PM cehteh: sample some input from rx, calibrate the clock with that, then go on, possibly adjust the clock on the go, but slowly with some deadband, OSCCAL is somewhat coarse
01:54 PM cehteh: and try to avoid the U2X bit if possible, it makes the rx samling even less accurate
01:55 PM hetii: Hi :)
01:56 PM fooman2011: cehteh: mmh I can try to avoid U2X
01:57 PM cehteh: having an accurate clock comes first and make it a dent faster than you need
01:57 PM cehteh: if slower then echoing back will stall
02:08 PM hetii: I build such psu: https://snag.gy/GngS41.jpg and I wonder how high voltage I should have on emiter of TIP35 without load and when set dac to 0 because currently I got 4.6v
02:18 PM hetii: hmm
02:19 PM hetii: it`s a bit odd, when I use led instead my lamp and the voltage drop to 0v, then I increment value in dac by +1 and then I got 0.01 after value in dac is above 600.
02:22 PM hetii: so my imagination was that I take the input voltage so 17v divide it by dac resolution so 4095 then got smallest possible voltage on output so to get to get 2.5v I should put into dac value 600 -> 600steps×(17v÷4095dac)~2.49v
02:42 PM day__ is now known as daey
02:52 PM fooman2011: In the attiny2313A http://www.atmel.com/images/doc8246.pdf page 30. There is a schema to use an external crystal. There are 2 capacitors. Could you please tell me if they are ceramic type capacitors ?
02:55 PM Emil: Hm?
02:55 PM Emil: Someone had a question?
03:03 PM hetii: fooman2011, yes
03:03 PM day__ is now known as daey
03:04 PM hetii: fooman2011, general for crystal you always have ceramic type capacitors with small values on teen of pF
03:05 PM Emil: 2-20pF
03:05 PM Emil: Around that
03:06 PM hetii: *tens
03:06 PM hetii: yep
03:07 PM fooman2011: Yes 12-22pF recommanded
03:11 PM Emil: fooman2011: it depends on the stray capacitance
03:17 PM polprog: nohitzzz: did you realize that in HW? or in software? i remember there was lmms plugin for sid synthesis emulation
03:17 PM polprog: it's pretty good
03:18 PM polprog: fooman2011: IIRC crystals have the capacitance given in the datasheet
03:19 PM polprog: fooman2011: I got a steady 9600 on an atmega8 with internal oscillator; had to enable U2X to minimize the error rate.
03:19 PM polprog: fooman2011: the formulas for UBRR are given in the datasheet and in avr-libc as macros
03:21 PM polprog: nohitzzz: this was blasting in the school recently: https://www.youtube.com/watch?v=R9yLJoD2hz8 ;)
03:22 PM nohitzzz: software
03:22 PM polprog: which one?
03:22 PM polprog: i feel like im back to playing piano
03:22 PM nohitzzz: quadraSID
03:23 PM nohitzzz: its sadly discontinued product. but i have another one
03:23 PM polprog: hmm i had a feeling i heard 4 tracks there ;)
03:23 PM nohitzzz: http://www.hypersynth.com/sidizer.html
03:23 PM polprog: now for something completely different
03:23 PM polprog: https://puu.sh/yw7vr/f3f7fd1d55.jpg
03:24 PM polprog: i tore down a broken smart wristband
03:24 PM polprog: we got it as an extra when we bought our server machine from the recycler
03:25 PM polprog: it has significant liquid damage and it displays "eeprom ee" on it's OLED display, the battery was dead as wll
03:25 PM nohitzzz: cool
03:25 PM polprog: my question is if the NRF module on that pic is worth desoldering
03:26 PM polprog: i also had a poke around on the oled screen signals, it works and seems to have a simple protocol. ill look for the datasheet later
03:26 PM polprog: the it's probably a bt module
03:26 PM polprog: i could desolder it with hot air, given that it wont die in the process. or use some other smd removal techniques
03:27 PM Ameisen: that reminds me
03:27 PM Ameisen: need to write my structured eeprom thing
03:28 PM Ameisen: I want to have actual data structures in it rather than a binary stream
03:28 PM Ameisen: makes versioning/adding features easier
03:28 PM Ameisen: adds a little bit of overhead though
03:28 PM polprog: eeprom of what?
03:28 PM Ameisen: printer firmware
03:28 PM polprog: ah
03:28 PM Ameisen: adding featuers right now basically means 'add new options to end of eeprom'
03:28 PM Ameisen: and removing features means 'oh well.'
03:28 PM Ameisen: since you don't want to change the eeprom structure, since it's read as a stream of bits
03:28 PM Ameisen: I would rather it basically be a container structure
03:29 PM Ameisen: then you can reorganize the eeprom whenever, still reads the same
03:31 PM polprog: nmm, nrf d 8001, a ble chip
03:31 PM polprog: looks cool. integrated module with a crystal and SMD antennae
03:31 PM Ameisen: basically, every 'system' would define a structure that is its options (each variable would likely have a hash ID), and the system itself would have a hash ID
03:32 PM Ameisen: so when you write the eeprom, you loop over the systems, write out the system hash, the option variables (hash:value pairs)
03:32 PM polprog: i'd make swappable cartridges for features
03:32 PM Ameisen: that way, when you read it, it doesn't matter what order things are, and such
03:32 PM Ameisen: plus, since it's pair-based, versioning is easier
03:32 PM polprog: so you can have a different printer configs for different jobs
03:32 PM Ameisen: you can just leave old hashes in, and define overriding behavior for them, when data changes
03:32 PM Ameisen: no having to clear the eeprom for a new firmware version
03:33 PM Ameisen: it adds a bit of space overhead though
03:33 PM Ameisen: the hash:value pairs can be elided if space is a huge issue
03:33 PM Ameisen: makes versioning harder
03:33 PM Emil: Ameisen: wot
03:33 PM Emil: Ameisen: eeprom is byte oriented on avr
03:33 PM polprog: that's the micro the whole wristband is based on
03:33 PM polprog: http://pdf1.alldatasheet.com/datasheet-pdf/view/947546/RENESAS/R5F101ED.html
03:34 PM Ameisen: Emil - your point?
03:34 PM polprog: ill need to have a poke around with the scope tomorrow
03:34 PM polprog: :P
03:34 PM Ameisen: everyhting in AVR (and basically all modern architectures) is byte-oriented
03:35 PM Ameisen: so that's sort of a null statement
03:35 PM Ameisen: addressing-wise, at least
03:35 PM Ameisen: though AVR has some fun instructions for accessing bits
03:46 PM Ameisen: So, I got the basics in for C++ constraint types.
03:46 PM Ameisen: looks weird in usage
03:46 PM Ameisen: trying to figure out 'simpler' ways to use it
03:46 PM Ameisen: user-defined attributes would be helpful
03:47 PM polprog: this is terrible. i see this particular oled screen on google images (best way to search odd parts), but no info on pinout of the 14 pin flex cable :((
03:48 PM Ameisen: one thing I need to figure out is how to handle native promotion, unsigned-only promotion, and 'strong' types (that don't promote at all)
03:48 PM Ameisen: as they are three different concepts all together
03:48 PM polprog: looks like it can be interfaced by every major bus tho
03:48 PM Ameisen: and can cause different problems
04:02 PM polprog: testbed: http://picpaste.com/IMG_20171129_225221-JQQFLvIo.jpg
04:02 PM polprog: (reused pcb after a different proto)
04:04 PM polprog: night
04:05 PM nohitzzz: nite
08:23 PM enh: cehteh? Awake?
08:59 PM rue_mohr: polprog, what is the display from?
11:51 PM day__ is now known as daey