#avr | Logs for 2016-06-11

Back
[06:50:42] <neuro_sys> Hi, what this assembly snippet does is to look up a value from an array with an 16-bit offset and return it, right? https://gist.github.com/neuro-sys/40b10d2c0971e49ab9e2c4e07589d9fe
[06:51:00] <neuro_sys> (and returns an 8-bit number, right?)
[08:38:20] <lowin> Why does the computer give my device an IN request following SET_ADDRESS setup request? it confuses my device and I don't know how to handle it
[09:07:45] <Tom_itx> be much more specific
[09:13:02] <carabia> if you are unable to handle situations, you can always consult a shrink
[09:54:13] <Lambda_Aurigae> carabia, or a sex counselor.
[09:54:15] <Lambda_Aurigae> but,,
[11:09:13] <_ami_> any good articles on explaining basics of sound generation via AVR chips?
[11:49:46] <Lambda_Aurigae> _ami_, there are a couple of appnotes from atmel
[11:51:50] <Lambda_Aurigae> http://extremeelectronics.co.in/avr-tutorials/sound-generation-by-avr-micro-tutorial-i/
[11:52:00] <Lambda_Aurigae> not seeing the appnote for playback, only one for recording.
[11:53:26] <_ami_> Lambda_Aurigae: its just have code.
[11:53:34] <_ami_> i needed a bit theory though.
[11:54:02] <_ami_> something which explains about sound, its frequency etcs
[11:54:46] <_ami_> i am currently watching this: https://www.youtube.com/watch?v=4byHVqXD-UI introduction explains a bit abt sound which is good.
[11:55:33] <_ami_> i am thinking of starting with beep and then move to actual sound generation.
[11:56:26] <Lambda_Aurigae> there are a couple of different ways to do it.
[11:56:49] <Lambda_Aurigae> traditional, like the old ibm pc built in speaker did it, was just to toggle an i/o pin to generate a tone.
[11:57:29] <Lambda_Aurigae> newer and more complex way is to use pwm to generate the tones. You can then just trigger the pwm to make the sound and wait till the next change and change the pwm.
[11:57:52] <Lambda_Aurigae> takes less processor time as the pwm can generate the tone asynchronously to the main app.
[11:58:44] <_ami_> Lambda_Aurigae: i understood pwm though. its just sound which i need to understand
[11:59:24] <Lambda_Aurigae> you can also use pwm to generate pseudo-analog levels, like you do for driving a motor,
[11:59:55] <Lambda_Aurigae> how to explain sound...it's a wave.
[12:00:03] <Lambda_Aurigae> a square wave sounds different from a sine wave
[12:01:41] <Lambda_Aurigae> are you wanting to play back recorded audio or just play notes?
[12:02:56] <_ami_> Lambda_Aurigae: i would start with play notes and then move to play back recorder audio. i think for play back audio, i might need some tool to convert it to int8 []?
[12:03:23] <Lambda_Aurigae> http://avrpcm.blogspot.com/2010/11/playing-8-bit-pcm-using-any-avr.html
[12:03:34] <Lambda_Aurigae> bit of a sample for playing back recorded audio.
[12:04:30] <Lambda_Aurigae> for playing notes,,,that's just simply toggling an i/o pin at the desired frequency for the desired duration.
[12:05:29] <Lambda_Aurigae> what I've done in the past is use a 4 bit or 8 bit r2r ladder DAC
[12:05:41] <Lambda_Aurigae> then you can adjust amplitude as well as frequency.
[12:06:12] <Lambda_Aurigae> using one 8bit i/o port you can even do dual 4-bit DAC for "stereo"
[12:06:41] <Lambda_Aurigae> just takes a bunch of resistors of the same value.
[12:08:04] <_ami_> okay, thanks
[12:08:30] <Lambda_Aurigae> there are also DAC chips.
[12:08:38] <Lambda_Aurigae> and some microcontrollers have built in DAC as well.
[12:08:51] <_ami_> i shall experiment with it today before Eng Vs Russia match starts! :)
[12:08:58] <Lambda_Aurigae> in the avr world I think you have to go to xmega for a DAC though.
[12:09:05] <_ami_> Lambda_Aurigae: AVR MCUs has? e.g. mega16a?
[12:09:11] <_ami_> ah
[12:09:12] <_ami_> ok
[12:09:17] <Lambda_Aurigae> atmega16 does not have DAC
[12:09:20] <Lambda_Aurigae> it has ADC
[12:09:32] <Lambda_Aurigae> DAC is easily done with an r2r ladder though.
[12:09:57] <Lambda_Aurigae> https://en.wikipedia.org/wiki/Resistor_ladder
[12:10:31] <_ami_> got it!
[12:10:34] <_ami_> cool.
[12:11:51] <Lambda_Aurigae> note that r2r ladders don't provide exactly,,,,quality audio.
[12:13:45] <Lambda_Aurigae> http://avrpcm.blogspot.com/2010/11/playing-8-bit-pcm-using-any-avr.html
[12:13:55] <Lambda_Aurigae> that actually does a better job of audio reproduction.
[12:14:33] <Lambda_Aurigae> or get an mp3 decoder chip.
[12:15:45] <_ami_> Lambda_Aurigae: the trick it uses is the sample count. which is 4. This results into approx sine wave?
[14:47:35] <evil_dan2wik> For some reason I ended up with 185 atmega328p processors. Anything cool I can do with them?
[14:47:59] <Lambda_Aurigae> build an avr cluster and rule the world!
[14:48:57] <Lambda_Aurigae> build a bunch of avr learning kits and teach kids how to use avr without arduino?
[14:53:09] <Lambda_Aurigae> install igorplug-udp on them and make sensors for your house and create a massive ethernet sensor array.
[16:14:02] <phinxy> Is there an tool / online webpage that flips endian-ness of bytes?
[16:20:35] <Tom_itx> http://www.ks.uiuc.edu/Development/MDTools/flipdcd/
[16:20:37] <Tom_itx> maybe
[16:41:01] <Tom_itx> http://esr.ibiblio.org/?p=5095
[16:42:42] <Tom_itx> http://stackoverflow.com/questions/2182002/convert-big-endian-to-little-endian-in-c-without-using-provided-func
[16:56:53] <phinxy> hmm its not the endian i want to change but MSB>LSB to LSB>MSB
[17:05:26] <Tom_itx> lifo
[17:09:14] <Tom_itx> http://www.engineersgarage.com/c-language-programs/implement-stack-and-perform-push-and-pop-operations
[17:09:38] <cehteh> just some shifts do the job
[17:26:21] <Chillum> can an atmega328 keep reasonable time without an external RTC? Like as good as a cheap digital watch?
[17:27:13] <LeoNerd> If it was clocked from a good enough source, sure
[17:27:48] <Chillum> just using the same 16mhz xtal that the nano uses
[17:28:07] <Tom_itx> doubtful
[17:28:12] <Chillum> good to know
[17:28:22] <Tom_itx> not a good 'clock' frequency
[17:28:39] <Tom_itx> 32.768khz clock crystal or a derivative thereof
[17:28:45] <Chillum> riight, that is why clock xtals have strange looking freqs
[17:28:56] <Chillum> I am adding a microsd slot to make log entries for solder jobs and I wanted to log timestamps
[17:29:20] <Chillum> not a really important feature. I guess I could add a DS3231 if I really cared
[17:35:24] <cehteh> its not about the strange frequency but about stability
[17:35:51] <cehteh> but even if you have a good crystal, usually you cant do much compensation, except in software
[17:50:24] <LeoNerd> Does anyone have an example of using the AVR SPI module as a slave..? All the examples I can find are -terrible-. They all leave MISO as a driven output permanently.
[17:50:35] <LeoNerd> Surely to be a wellbehaved slave, you leave it hiZ until you get your SS line asserted?
[17:51:09] <LeoNerd> But I can't see an interrupt that gets fired on those SS transitions... only after a complete set of 8 bits
[17:51:20] <LeoNerd> Hrm.. or should I just use the PCINT as normal?
[18:00:50] <Jartza> evening
[18:04:00] <LeoNerd> Hrm... OK so it does at least appear, that yes - pcint works as normal on the SS pin when in slave mode
[18:19:25] <LeoNerd> Mm.. this is actually working nicely :)
[18:26:02] <LeoNerd> Ibelieve I'm talking SPI to the buspirate
[18:26:24] <LeoNerd> Or rather, from