NUCLEO-F030R8_ExtXtalTest
main.cpp@2:216033df37ae, 2015-08-18 (annotated)
- Committer:
- nightseas
- Date:
- Tue Aug 18 10:35:14 2015 +0000
- Revision:
- 2:216033df37ae
- Parent:
- 1:c297d1519b5c
Verified with external 8MHz crystal
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nightseas | 0:190f0f0f96b5 | 1 | #include "mbed.h" |
nightseas | 0:190f0f0f96b5 | 2 | |
nightseas | 0:190f0f0f96b5 | 3 | DigitalOut myled(PB_12); |
nightseas | 0:190f0f0f96b5 | 4 | |
nightseas | 0:190f0f0f96b5 | 5 | void SystemClock_Config(void) |
nightseas | 0:190f0f0f96b5 | 6 | { |
nightseas | 0:190f0f0f96b5 | 7 | RCC_OscInitTypeDef RCC_OscInitStruct; |
nightseas | 0:190f0f0f96b5 | 8 | RCC_ClkInitTypeDef RCC_ClkInitStruct; |
nightseas | 0:190f0f0f96b5 | 9 | |
nightseas | 0:190f0f0f96b5 | 10 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
nightseas | 0:190f0f0f96b5 | 11 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
nightseas | 0:190f0f0f96b5 | 12 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
nightseas | 0:190f0f0f96b5 | 13 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
nightseas | 0:190f0f0f96b5 | 14 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6; |
nightseas | 0:190f0f0f96b5 | 15 | RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1; |
nightseas | 0:190f0f0f96b5 | 16 | HAL_RCC_OscConfig(&RCC_OscInitStruct); |
nightseas | 0:190f0f0f96b5 | 17 | |
nightseas | 0:190f0f0f96b5 | 18 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK; |
nightseas | 0:190f0f0f96b5 | 19 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
nightseas | 0:190f0f0f96b5 | 20 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
nightseas | 0:190f0f0f96b5 | 21 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
nightseas | 0:190f0f0f96b5 | 22 | HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1); |
nightseas | 0:190f0f0f96b5 | 23 | |
nightseas | 0:190f0f0f96b5 | 24 | SystemCoreClockUpdate(); |
nightseas | 0:190f0f0f96b5 | 25 | } |
nightseas | 0:190f0f0f96b5 | 26 | |
nightseas | 0:190f0f0f96b5 | 27 | int main() { |
nightseas | 0:190f0f0f96b5 | 28 | |
nightseas | 1:c297d1519b5c | 29 | //SystemClock_Config(); |
nightseas | 0:190f0f0f96b5 | 30 | |
nightseas | 0:190f0f0f96b5 | 31 | printf("SystemCoreClock = %d Hz\n\r", SystemCoreClock); |
nightseas | 0:190f0f0f96b5 | 32 | |
nightseas | 0:190f0f0f96b5 | 33 | while(1) { |
nightseas | 0:190f0f0f96b5 | 34 | myled = !myled; |
nightseas | 2:216033df37ae | 35 | wait(0.5); |
nightseas | 0:190f0f0f96b5 | 36 | } |
nightseas | 0:190f0f0f96b5 | 37 | } |