Question
STM32F103 is not fast enough
Hello,
Here is my code,
#include <stdio.h>
#include <string.h>
void GPIOSYS(void){
GPIO_InitTypeDef GPIOSt;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
//GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
GPIOSt.GPIO_Mode=GPIO_Mode_Out_PP;
GPIOSt.GPIO_Pin=GPIO_Pin_7|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_0|GPIO_Pin_1;
GPIOSt.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIOSt);
GPIO_PinRemapConfig(GPIO_Remap_USART2,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIOSt.GPIO_Mode=GPIO_Mode_Out_PP;
GPIOSt.GPIO_Pin=GPIO_Pin_2|GPIO_Pin_3;
GPIOSt.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIOSt);
}
void CLOCK(void){
RCC_HSEConfig(RCC_HSE_ON);
while(RCC_WaitForHSEStartUp()==ERROR);
RCC_PLLConfig(RCC_PLLSource_HSE_Div1,9);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus( RCC_FLAG_PLLRDY)!=SET);
RCC_ClockSecuritySystemCmd(ENABLE);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
RCC_HCLKConfig(RCC_SYSCLK_Div1);
while (RCC_GetSYSCLKSource() != 0x08);
}
void Delay(){
int i,j;
for(i=0;i<10000;i++)
for(j=0;j<250;j++);
}
int main(void){
CLOCK();
GPIOSYS();
while(1){
GPIO_ResetBits(GPIOB,GPIO_Pin_6);
GPIO_ResetBits(GPIOB,GPIO_Pin_7);
GPIO_ResetBits(GPIOA,GPIO_Pin_2);
GPIO_ResetBits(GPIOA,GPIO_Pin_3);
//Delay();
GPIO_SetBits(GPIOB,GPIO_Pin_6);
GPIO_SetBits(GPIOB,GPIO_Pin_7);
GPIO_SetBits(GPIOA,GPIO_Pin_2);
GPIO_SetBits(GPIOA,GPIO_Pin_3);
//Delay();
}
}
I see a 500Khz pulse train on my oscilloscope which is below my expectations( for a 72Mhz MCU). Did I make a mistake or it is usual?
Thanks