I have been using this same processor for the past 6 years. In all that time I have never used the Power Manager in ASF to set up my clocks, but rather System Clock Services. I even posted a how to in May of 2017 (https://www.avrfreaks.net/forum/...). But for some reason, the good times are over. I cannot get past the dreaded PLL not Locked.
I have tried previous software projects that worked before, I have tried different processor boards - some used to work, I just made two new ones - one failed immediately, the other ran for a while before it started failing.
I like using System Clock Services - it is easy to understand - setup the clock values in conf_clock.h and call sysclk_init(); No mess, no fuss - and now no PLL LOCK!
Here is the code I am using:
//conf_clock.h set cpu to 66 MHz #ifndef CONF_CLOCK_H_INCLUDED #define CONF_CLOCK_H_INCLUDED #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL0 /* Fbus = Fsys / (2 ^ BUS_div) */ #define CONFIG_SYSCLK_CPU_DIV 0 #define CONFIG_SYSCLK_PBA_DIV 0 #define CONFIG_SYSCLK_PBB_DIV 0 #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1 #define CONFIG_USBCLK_DIV 1 #define CONFIG_PLL0_SOURCE PLL_SRC_OSC0 #define CONFIG_PLL0_MUL 16 //(48000000UL / BOARD_OSC0_HZ) #define CONFIG_PLL0_DIV 3 #define CONFIG_PLL1_SOURCE PLL_SRC_OSC0 #define CONFIG_PLL1_MUL (48000000UL / BOARD_OSC0_HZ) #define CONFIG_PLL1_DIV 1 #endif /* CONF_CLOCK_H_INCLUDED */ ----------------------------------------------------------- //user_board.h #ifndef USER_BOARD_H #define USER_BOARD_H #include <conf_board.h> /* Clock Speed */ #define APPLI_CPU_SPEED 66000000 #define APPLI_PBA_SPEED 66000000 /* These are documented in services/basic/clock/uc3b0_b1/osc.h */ #define BOARD_OSC0_HZ 12000000 #define BOARD_OSC0_STARTUP_US 17000 #define BOARD_OSC0_IS_XTAL true #define BOARD_OSC32_HZ 32768 #define BOARD_OSC32_STARTUP_US 71000 #define BOARD_OSC32_IS_XTAL true #define FOSC0 12000000 #define CLOCK_PBA_FREQ 66000000 #define Test_Pin AVR32_PIN_PA19 #endif // USER_BOARD_H -------------------------------------------------------------------------- //init.c #include <asf.h> #include <board.h> #include <conf_board.h> #include <user_board.h> void IO_Init(void); void board_init(void) { sysclk_init(); gpio_local_init(); IO_Init(); } void IO_Init(void) { gpio_local_enable_pin_output_driver(Test_Pin); } ----------------------------------------------------------------- //main.c #include <asf.h> #include <user_board.h> int main (void) { int c; flash_set_wait_state(1); board_init(); while (1) { gpio_local_tgl_pin(Test_Pin); } }
As I mentioned - one of the new assembled boards ran for a while before failing to the no PLL - the output pin was producing a waveform with a 90ns pulse.
The only thing I have not tried is changing the JTAGICE - I have a second one, so I guess I should give it a try since I have been using the current one for 5 years - that would eliminate one more possibility.
I, as always, would welcome some thoughts on this strange, fustrating, problem.
Kind regards,
David