x
Revision 0:86b437ce0d0f, committed 2018-07-23
- Comitter:
- JackB
- Date:
- Mon Jul 23 12:25:39 2018 +0000
- Commit message:
- SC
Changed in this revision
SystemClock.cpp | Show annotated file Show diff for this revision Revisions of this file |
SystemClock.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 86b437ce0d0f SystemClock.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SystemClock.cpp Mon Jul 23 12:25:39 2018 +0000 @@ -0,0 +1,74 @@ +// ST_401_84MHZ +// https://os.mbed.com/users/dreschpe/code/ST_401_84MHZ/ +// If you want to use a different crystal or frequency : the STM32CubeMX tool is your friend :-) +// use the STM32CubeMX Tool to calculate the register settings +// www.st.com/stm32cube +// + +//#include "stm32f4xx_hal.h" +//#include "ST_F401_84MHZ.h" +// +//F401_init84::F401_init84(unsigned int external){ +// if(external == 1){ +// SystemClock_Config_84MHz_external(); +// } +// else { +// SystemClock_Config_84MHz_internal(); +// } +// } +// +//void F401_init84::SystemClock_Config_84MHz_internal(void) +//{ +// HAL_RCC_DeInit(); // we have to reset the clock settings ! +// RCC_ClkInitTypeDef RCC_ClkInitStruct; +// RCC_OscInitTypeDef RCC_OscInitStruct; +// +// RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; // internal 16MHz RC +// RCC_OscInitStruct.HSIState = RCC_HSI_ON; +// RCC_OscInitStruct.HSICalibrationValue = 6; +// RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; // PLL on +// RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; +// RCC_OscInitStruct.PLL.PLLM = 16; // setup PLL divider +// RCC_OscInitStruct.PLL.PLLN = 336; +// RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; +// RCC_OscInitStruct.PLL.PLLQ = 4; +// HAL_RCC_OscConfig(&RCC_OscInitStruct); +// +// RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1; +// RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; +// RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; +// HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); +// SystemCoreClockUpdate(); // update SystemCoreClock var +//} +// +// +//// use a external 8 MHz crystal to generate the CPU clock +//// You have to add X3 8MHz +//// C33,C34 18pF 0603 +//// R35,R37 0R 0603 or use wire +// +// +//void F401_init84::SystemClock_Config_84MHz_external(void) +//{ +// HAL_RCC_DeInit(); // we have to reset the clock settings ! +// RCC_ClkInitTypeDef RCC_ClkInitStruct; +// RCC_OscInitTypeDef RCC_OscInitStruct; +// +// RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE; +// RCC_OscInitStruct.HSEState = RCC_HSE_ON; +// RCC_OscInitStruct.LSIState = RCC_LSI_ON; +// RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; +// RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; +// RCC_OscInitStruct.PLL.PLLM = 8; +// RCC_OscInitStruct.PLL.PLLN = 336; +// RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; +// RCC_OscInitStruct.PLL.PLLQ = 4; +// HAL_RCC_OscConfig(&RCC_OscInitStruct); +// +// RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1; +// RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; +// RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; +// HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); +// SystemCoreClockUpdate(); // update SystemCoreClock var +// +//}
diff -r 000000000000 -r 86b437ce0d0f SystemClock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SystemClock.h Mon Jul 23 12:25:39 2018 +0000 @@ -0,0 +1,44 @@ +///* mbed library for the ST NUCLEO board F401RE +// * to change the CPU clock to 84 MHz +// * +// * Copyright (c) 2014 Peter Drescher - DC2PD +// * Released under the MIT License: http://mbed.org/license/mit +// * +// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// * THE SOFTWARE. +// */ +//#ifndef MBED_ST_F401_84MHZ_H +//#define MBED_ST_F401_84MHZ_H +// +///** Setup speed to 84 MHz +// * +// * @code +// * #include "mbed.h" +// * #include "ST_F401_84MHZ.h" +// * +// * // place the init before other code to ensure right timing of other objects ! +// * F401_init84 myinit(0); // use the internal oscillator +// * +// */ +// +//class F401_init84 +//{ +//public: +// /** Create a F401_init84 object to change the clock +// * @param external = 0 use internal oscillator +// * @param external = 1 use external 8 MHz crystal - you have to add some comonents to the pcb ! +//*/ +//F401_init84(unsigned int external); +// +//protected: +//// do the magic ;-) +//void SystemClock_Config_84MHz_internal(void); +//void SystemClock_Config_84MHz_external(void); +//}; +// +//#endif