Trying to bring up an Xmega32A4 board of my own design. Got PORT D to flash, but the clock configuration code I added next disappoints. Based on the forum posts on this topic I whittled it down to what you see here. The problems are:
1. CLK.CTRL = 0x02; has no effect, so the chip never switches from 2 MHz to 32 MHz.
2. Nothing I try turns off the 2 MHz internal oscillator. Not a huge problem, but just curious why I'm not able to. May be related to 1., above; the chip may prevent me from disabling a clock source if another one isn't selected.
I'm using ICCAVR, AVR Studio 4, and JTAGICE Mk II, however I've duplicated the problem in AVR-GCC.
Thanks for any suggestions.
#include#include void ClockConfig(void) { OSC.CTRL |= 0x02; // Enable 32MHz internal oscillator while (!( OSC.STATUS & 0x02)); // Wait for oscillator to stabilize CLK.CTRL = 0x02; // Select 32MHz internal oscillator OSC.CTRL &= 0x02; // Turn off 2MHz internal oscillator } int main(void) { char x = 0; ClockConfig(); // Insert code PORTD.DIR=0xff; PORTD.OUTSET = 0xff; while (1) { PORTD.OUTTGL = 0xff; } return 0; }