creating an IR remote with arduino

Hello massimo,

Thanks for the help. I looked through the ATmega8 docs and I think I found the basics of what I need to know. It tells me that I can set the PWM frequency with the following equation: fclk_I/O / N * (1 TOP)

The docs also state that "However, if the base PWM frequency is actively changed (by changing the TOP value), using the OCR1A as TOP is clearly a better choice due to its double buffer feature."

In the end I hope that its as simple as #1 determining the clock I/O speed, #2 setting the TOP value to the divisor that will yeild the correct frequency (using the OCR1A register), and #3 setting the PWM duty cycle to 50% (127) to ensure an equal length of time off and on. I hope that once I have finished steps #1 and #2, that I can analogWrite(pin9, 127) and end up with a PWM output modulated at 40kHz.

The tricky thing for me is that I can play with predefined methods fine, but I don't have assembly experience. I don't know what the value of the clk_I/O is and I don't know how to set TOP to the value I want using the OCR1A register.

Could you please tell me if I'm on the right track or not? If I am on the right track, could you tell me what the clk_I/O is for arduino and how to set the TOP value using the OCR1A register?

This is my first embedded experience, so although I read through the PWM sections of the ATmega8 documentation there was alot I was not understanding.

Thanks a ton for the help,
Mark