#avr | Logs for 2014-02-13

Back
[07:19:26] <inflex> looks like the wifi chipset on my ADSL modem/router crapped out in a partial way
[07:19:37] <inflex> If I stay on for more than an hour here then things might be okay
[07:26:40] <inflex> whoops, wrong channel
[07:27:09] * GuShH_ slaps inflex around
[07:39:34] <inflex> :-(
[10:44:16] * twnqx cracks braincracker
[10:45:24] <braincracker> hello my friends
[16:28:47] <braincracker> ping!
[16:32:35] <alasdairc> can anyone help me setup TIMER1 for 36-40KHz phase correct wave generation on a TINY84 running on a 12Mhz crystal. I'm totally stumped.
[16:33:14] <alasdairc> i have code which runs perfectly at 8MHz, and in theory this takes into account F_CPU, but somewhere my maths is going wrong
[16:37:20] <alasdairc> this is the code which sets up the timer: http://www.pastebin.ca/2640180
[16:37:55] <antto> what is val?
[16:41:22] <alasdairc> the frequency of the waveform, it's an IR sender, so it's could be between 36-40KHz
[16:41:55] <antto> what's its value i mean
[16:42:09] <alasdairc> actually while I think about it I only need to generate one frequency, 40KHz
[16:42:16] <alasdairc> 40
[16:42:27] <antto> and what is F_CPU?
[16:42:44] <alasdairc> 12000000
[16:44:28] <alasdairc> i modify the width by setting/clearing COM1A1 bit for specific microsecond lengths
[16:45:12] <antto> my calculator says this is gonna give you 80kHz
[16:46:43] <alasdairc> ok - so my brain is now shouting at me multiply by two and run!
[16:47:04] <alasdairc> can you tell me how you calculate that?
[16:47:27] <antto> not sure if i'm right but..
[16:47:58] <antto> F_CPU/pwmval
[16:48:13] <antto> ehm, the prescaler should be included in this
[16:48:23] <antto> (F_CPU/prescaler)/pwmval
[16:49:01] <antto> so with prescaler of 2, it'd be (F_CPU/2)/pwmval which would be 40kHz
[16:52:27] <alasdairc> im trying this out
[16:52:35] <alasdairc> thanks
[16:53:47] <alasdairc> I don't understand why ICR1 and OCR1A are both set , particularly OCR1A = pwm/3 (this is code from an arduino library)
[16:58:45] <alasdairc> the prescaler is 0. but thinking about this the function works at 8MHz fine. putting in val=40 F_CPU=8000000 gives me 80KHz too..
[16:59:15] <PoppaVic> Someday, I need to create a table of all the idjit MACROS for arduino and avr - just so I can follow the C, (let alone asm)
[17:03:58] <alasdairc> yeah macros can be evil
[17:08:01] <PoppaVic> alasdairc: nah, it's that I see herein things I don't see in #arduino and sites for that. So, that tells me the c++ freaks are hiding crap - and the C crap is predicated on.. Datasheets? Something. I need to reconcile the two - I loathe c++ other than the idea of namespaces.
[17:08:35] <PoppaVic> (forth users know about namespaces in sane ways ;-)
[19:29:32] <sirpatrick> If I need to read a certain register over SPI, how do I select that register?
[19:44:34] <sirpatrick> it looks like your just transfer the address, and then begin reading right after