SparkFun Forums 

Where electronics enthusiasts find answers.

Everything ARM and LPC
By Cyberzim
I've just started working with the ARM-processors. I've currently written some code for working with my 5,7" display. Now I'm trying to increase my processor speed. My board (Olimex STM32-H107) has a 25 MHz external clock.
I'm trying to get a 50MHz speed, but I don't seem to get any improvements at all.
Here is my code based on the RM0008 reference manual:
Code: Select all
//External clock enable.
  RCC_CR |= (1 << RCC_CR_HSEON_BIT);
  while(!(RCC_CR & 0x20000));
  //Sets HSE prescale by 2.

  //Use HSE as PLL input.

  //Set flash prefetch.

  //Set multiplier to x4.
  RCC_CFGR |= (1 << 19);
  //Enable Pll.
  while((RCC_CR & RCC_CR_PLLRDY) == 0);
What am I doing wrong? And also: What is the highest speed possible with a 25MHz external crystal?


Simon H.A.
By UhClem
I don't see the code to connect the PLL output to anything.

If you are using the system init file (system_stm32f10x.c) then you can change some #defines there to configure the clock system.
By Cyberzim
I'm using the CrossWorks compiler. Does it have a system init file?
And what do you mean with that the PLL is not connection to anything? I've selected HSE as PLL input and enabled PLL. Isn't that enough?
By Cyberzim
I managed to get a much higher speed by doing some better reading on the reference manual. I'm not sure what the speed is. With my ST-LINK the number of cycles is around 150,000,000/sec.
I got the speed I need. Can you figure out what my speed is? Here is my code:
Code: Select all
//External clock enable.
  RCC_CR |= (1 << RCC_CR_HSEON_BIT);
  while( (RCC_CR & RCC_CR_HSERDY) == 0);
  //Flash latency = two wait states.
  FLASH_ACR |= (0 << 0);
  FLASH_ACR |= (1 << 1);
  FLASH_ACR |= (0 << 0);

  //HSE as PLL entry clock source.

  //PLL as system clock.
  RCC_CFGR |= (1 << 1);

  //SYSCLK divided by 0.
  RCC_CFGR |= (0 << 7);

  //PLL x12
  RCC_CFGR |= (1 << 19);
  RCC_CFGR |= (1 << 21);

  //Enable PLL.
  RCC_CR |= (1 << RCC_CR_PLLON_BIT);
  while((RCC_CR & RCC_CR_PLLRDY) == 0);
Edit: My external crystal is 25MHz.


Simon H.A.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]