Hi, I'm new at Atmega microcontollers and I'm not a pro in the game so I need your help :)
I have an Arduino Uno Rev3 to do my project and I will work with the Atmega16u2.
Since the Arduino board apply a 16MHz external crystal oscilator to Atmega16u2, generate a clock signal with 4Mhz don't seem to be a problem.
Generate a 4MHz clock signal with CTC mode should be something like that:
TCNT0=0; // initialize the counter to 0
OCR0A=4; // Compare to 4 cycles (16MHz/4MHz = 4MHz toggle)
TCCR0A = 0x42; // Toggle OC0A on Compare Match, CTC Mode
TCCR0B = 0x01; // No Prescaler
I not tested this code yet because it's not I want to do. I want to generate a specific 3.58Mhz clock signal on the OC0A pin.
How can I do that? What value OCR0A should be to the OC0A pin toggle at 3.58MHz?
Thank you in an advance for your help!