how to overclock?

Post here first, or if you can't find a relevant section!
Post Reply
georgesshed
Posts: 6
Joined: Mon May 18, 2020 5:17 pm

how to overclock?

Post by georgesshed »

Hi all,

I have a STM32f103C8T6 "blue pill" and im using it to drive a ST7735 LCD. Its drawing an 'artificial horizon'. Currently im getting at most 8 FPS and drops down to 6 fps at large angles. This is way to slow for what i want.

I believe its possible to overclock to as much as 128Mhz but have not found a solid way to do this.

I found this code below which only works on 1/5 of the boards that I have. All the rest do nothing beyond a MUL of 10. This is very odd. A MUL of 10 works on all the boards and gives me an extra fps but beyond this nothing, just a blank screen. I thought they could have been fakes but i bought some new genuine ones with the same result.

Any ideas/ tutorials?

Thanks!

Code: Select all

extern "C" void SystemClock_Config(void)

void setup() {
.....
}

void loop() {

SystemClock_Config()
....
}

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

  /** Configure the main internal regulator output voltage 
  */
  HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1);
  /** Initializes the CPU, AHB and APB busses clocks 
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV8;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the CPU, AHB and APB busses clocks 
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    Error_Handler();
  }
  /** Initializes the peripherals clocks 
  */
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_ADC;
  PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK1;
  PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_SYSCLK;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  {
    Error_Handler();
  }
}

GonzoG
Posts: 80
Joined: Wed Jan 15, 2020 11:30 am
Answers: 5

Re: how to overclock?

Post by GonzoG »

If you overclock MCU you will loose some interfaces (like USB, IIC, UART).
It's better to find better LCD libraries or use LCD with parallel interface.

georgesshed
Posts: 6
Joined: Mon May 18, 2020 5:17 pm

Re: how to overclock?

Post by georgesshed »

Thanks for the comment. I dont need USb or UART functionality and am programming via ftdi. Using the eSPI libraty which is one of the fastest librarys there is. The ST7735 does not have a parallel interface, neither does any other 3.5 inch lcd ive found.

mlundin
Posts: 35
Joined: Wed Nov 04, 2020 1:20 pm
Answers: 2

Re: how to overclock?

Post by mlundin »

Cannot see any MUL in the posted code ?

Do you have PLL off as the posted code says, RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; ?

Do you call the SystemClock_Config() at the beginning of every loop ?

User avatar
fpiSTM
Posts: 848
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 33
Location: Le Mans
Contact:

Re: how to overclock?

Post by fpiSTM »

As spotted by @mlundin you don't need to call the SystemClock_Config().
Only define them and it will be used instead of the weaked one.

ag123
Posts: 517
Joined: Thu Dec 19, 2019 5:30 am
Answers: 1

Re: how to overclock?

Post by ag123 »

generally playing with clocks is to play with the pll clock multipliers.
the place to start is to readup the clock tree information in the ref manual.
google search rm0008 should get you there
https://www.st.com/resource/en/referenc ... ronics.pdf

i messed with F4 at one point and wrote a little python script to choose pll multipliers on F4
viewtopic.php?f=41&t=78
in my script i explore the clock multipliers which keeps usb at 48 mhz so that usb works, i did get some rather interesting results on the f4
viewtopic.php?f=7&t=27&start=20
viewtopic.php?p=550#p550

stm32f103 has a different and somewhat more limited pll clock multipliers, so i'd guess you'd need to figure out the same.

messing with the clock multipliers is 'quite basic' but hard for beginners, so beginners are better off starting with a supported board.
more often than not when one starts with a different board with a different HSE crystal frequency the board will simply stall/hang if you simply select another board with the same mcu and compile. the catch is nearly always the crystal is at a different frequency so you'd need to find the appropriate pll clock multipliers to get the new board to work the same way

Post Reply

Return to “General discussion”