PlatformIO

 

 A student wanted to use PlatformIO for coding. I have heard of it for a while and would like to give it a try. It has an advantage of covering many platforms: stm32, avr, pic32. It provides all the tools (compiler and uploader) in a single installation. And it is rich in editing features. It also provides a number of popular frameworks such as arduino (I don't like it but its really good for high school students and hobbyist).

I just tested it for our black pill board. It works!

There is only one difference. It changes the stm32 header file to stm32f1xx.h. Whereas keil uses stm32f10x.h

AVR - non arduino


System Clock Setting on STM32F103 Project

The default setting in PlatformIO is found to be 8 MHz for APB2. The setting in Keil is 72 MHz for APB2 and 36 MHz for APB1. The following code will boost up the frequencies.

  RCC->CFGR = RCC_CFGR_PLLMULL9 | RCC_CFGR_PLLSRC | RCC_CFGR_PPRE1_DIV2;
  RCC->CR |= RCC_CR_HSEON;
  while (!(RCC->CR & RCC_CR_HSERDY));
  RCC->CR |= RCC_CR_PLLON;
  while (!(RCC->CR & RCC_CR_PLLRDY));
  FLASH->ACR |= FLASH_ACR_LATENCY_2;
  RCC->CFGR |= RCC_CFGR_SW_PLL;
  while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL);
  RCC->CR &= ~RCC_CR_HSION;

留言

這個網誌中的熱門文章

EIE3105 / EIE3106 Robot Car Info (2024 Jan - Apr) - Integrated Project

PolyU EIE3105 / EIE3106 (2022-2023) EIE JoyPad & MCU Control PCBs - Important Note (Robot Car) - Integrated Project

PID Speed Control