From a42813c756c0c0be593faa246ef5eda1d52e5fcd Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 23 Feb 2015 17:27:28 -0600 Subject: [PATCH] PIC32MZ: Fix some PLL setup logic --- arch/mips/src/pic32mz/pic32mz-config.h | 16 ++++++++-------- configs/pic32mz-starterkit/include/board.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/mips/src/pic32mz/pic32mz-config.h b/arch/mips/src/pic32mz/pic32mz-config.h index c00062a96b..bbbc383817 100644 --- a/arch/mips/src/pic32mz/pic32mz-config.h +++ b/arch/mips/src/pic32mz/pic32mz-config.h @@ -207,21 +207,21 @@ /* System PLL Divided Input Clock Frequency Range bits */ -#if BOARD_PLL_INPUT < 5000000 -# error BOARD_PLL_INPUT too low +#if (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 5000000 +# error BOARD_PLL_INPUT / BOARD_PLL_IDIV too low # define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_BYPASS /* < 5 MHz */ -#elif BOARD_PLL_INPUT < 9000000 +#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 9000000 # define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_5_10MHZ /* 5-10 MHz */ -#elif BOARD_PLL_INPUT < 14500000 +#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 14500000 # define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_8_16MHZ /* 8-16 MHz */ -#elif BOARD_PLL_INPUT < 23500000 +#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 23500000 # define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_13_26MHZ /* 13-26 MHz */ -#elif BOARD_PLL_INPUT < 39000000 +#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 39000000 # define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_21_42MHZ /* 21-42 MHz */ -#elif BOARD_PLL_INPUT < 64000000 +#elif (BOARD_PLL_INPUT / BOARD_PLL_IDIV) < 64000000 # define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_34_64MHZ /* 36-64 MHz */ #else -# error BOARD_PLL_INPUT too high +# error BOARD_PLL_INPUT / BOARD_PLL_IDIV too high # define CONFIG_PIC32MZ_FPLLRNG DEVCFG2_FPLLRNG_34_64MHZ /* 36-64 MHz */ #endif diff --git a/configs/pic32mz-starterkit/include/board.h b/configs/pic32mz-starterkit/include/board.h index 0783095490..6b060f9c38 100644 --- a/configs/pic32mz-starterkit/include/board.h +++ b/configs/pic32mz-starterkit/include/board.h @@ -59,7 +59,7 @@ /* Oscillator modes */ -#define BOARD_FNOSC_POSC 1 /* Use primary oscillator */ +#define BOARD_FNOSC_SPLL 1 /* Use system PLL */ #define BOARD_POSC_HSMODE 1 /* High-speed crystal (HS) mode */ /* PLL configuration and resulting CPU clock.