Hi guys,
I am using spi communication between the atmega328 and a bluetooth IC. The bluetooth needs its own 16mhz crystal to operate too. But, there is an option in the datasheet to just drive one of the bluetooth chip's crystal pins with a 16mhz signal. Board space is limited on this project and one less crystal would be handy.
I looked at the atmega datasheet and it looks like PB0(clkO) which is digital pin 8 should be the pin to output the system clock. I found this code but do not fully understand direct port manipulation yet:
void setup(void)
{
DDRB = _BV(DDB1); //set OC1A/PB1 as output (Arduino pin D9, DIP pin 15)
TCCR1A = _BV(COM1A0); //toggle OC1A on compare match
OCR1A = 0; //top value for counter
TCCR1B = _BV(WGM12) | _BV(CS10); //CTC mode, prescaler clock/1
}
void loop(void)
{
}
It outputs a 1MHZ signal to digital pin 9. I changed the OCR1A to 0 and got 8mhz (but I still need double that!). I thought changing DDB1 to DDB0 would output on pin8 but it just stopped it from working.
Any help is appreciated. I read the arduino page on port manipulation, but most of these symbols don't come up there. Maybe someone has a good link to a page on how to use this type of code or can help describe what it does.
Thanks