Hi,
now i found the problem, that in the function osc_enable_external() in osc.h there is the following code with the remark: "No external oscillator on the selected board"!:
static inline void osc_enable_external(uint8_t id) { Assert(false); // No external oscillator on the selected board } #endif
How should i tell the ASF, that my controller has an external oscillator?
Hacking the program by enable the oscillator with my own code runs, but i would like to do it the right way...
Previous post "ASF Project hangs waiting for stable clock":
i just started with ASF.
My startup project is a simple "Hello World"-Project just flashing a led on startup, with the following user board configuration:
- ATxmega32E5
- Internal 2MHz System clock from 8MHz clock (default setting)
- External 32'768Hz Crystal on the TOSC pins for the RTC running with 1kHz.
Test with clocks on Ports:
PORTCFG.CLKOUT = (PORTCFG_CLKOUT_PD7_gc | PORTCFG_RTCOUT_PD6_gc);
First i started with only the "Generic board support" module initializing the Ports and flashing the led.
The "System Clock" module wasn't needed, since it is already default on 2MHz from 8MHz.
-> OK, the Clock i can see on the Port PD7
Then i added the ASF RTC driver with the following settings recommended in http://asf.atmel.com/docs/3.22.0...
conf_rtc.h:
#define CONFIG_RTC_PRESCALER RTC_PRESCALER_DIV256_gc
conf_clock.h:
#define CONFIG_RTC_SOURCE SYSCLK_RTCSRC_TOSC
and added the functions
sysclk_init();
rtc_init();
just before the board_init(); function.
But the program hangs in the sysclk_rtcsrc_enable() function waiting for the oscillator ready....
Since on the first Test i didn't need the sysclk_init() because it is already default, i obviously need it is requested in the Quick start guide.
Removing it, results in a running program but only with the 2MHz System Clock...
Also while debugging in the sysclk_rtcsrc_enable function (with optimize none, debug max) the debugger omits the osc_enable(OSC_ID_XOSC);
But this could be a bug in Atmel studio, because adding a asm("NOP"), just before ommitted just the NOP, but the program hangs anyway...
static inline void sysclk_rtcsrc_enable(uint8_t id) { Assert((id & ~CLK_RTCSRC_gm) == 0); switch (id) { case SYSCLK_RTCSRC_RCOSC: #if !XMEGA_A && !XMEGA_D case SYSCLK_RTCSRC_RCOSC32: #endif osc_enable(OSC_ID_RC32KHZ); osc_wait_ready(OSC_ID_RC32KHZ); break; case SYSCLK_RTCSRC_TOSC: case SYSCLK_RTCSRC_TOSC32: #if !XMEGA_A && !XMEGA_D case SYSCLK_RTCSRC_EXTCLK: #endif asm("NOP"); // added by me osc_enable(OSC_ID_XOSC); osc_wait_ready(OSC_ID_XOSC); break; } CLK.RTCCTRL = id | CLK_RTCEN_bm; }