I'm using an ATMega324 and want to run it at 20MHz, while maintaining fast and reliable serial comm at 115200 bauds.
I've seen megas can use an external clock XCKn for the UART when used in synchronous mode.
So my setup is as follow :
-Mega324 XTAL1/2 to a 20MHz crystal (on STK500)
-External crystal oscillator at 3.6864MHz with output pin connected to PD4(XCK1)
-PD2/3(RXD1/TXD1) connected to STK500 spare 232.
I first tried the uart connection with a 11.0592Mhz crystal for the avr in asynchronous mode, and comm was ok.
But I can't get the mixed clock version working.
It definitely sends something (garbage) and if I disconnect the XCK1 it stops, so it seems to be using the external clock.
Using the following C code : (with Peter Fleury's lib)
uart1_init( UART_BAUD_SELECT(115200,3686400UL)); UCSR1C|=_BV(UMSEL10); // synchronous mode sei(); for(;;) uart1_puts_P("\n#hello world\n");
I read about the URSELn trick, but the 324 seems to have separate registers.
Anybody succeeded with such a config ?
Thanks