explain :1, The development software used in this blog is MDK5(KEIL5);
2, Single chip microcomputer for stm32f103zet6
3, This blog is suitable for people who have certain knowledge C And MCU based beginners
one , Download and install MDK5
I learned before 51 I used it when I was young Keil4, But there are difficulties in adding chips . So download and install it MDK5, Do you have an online search
A lot of resources .
two , Build a project
Reference blog :STM32F1 Explanation of firmware library file and creation based on firmware library MDK Engineering formwork
three , The first routine
objective : Connect to PB5 and PE5 Oral LED The lights flashed and went out
int main(void)
{
//GPIO,General Purpose Input Output , General I / O
GPIO_InitTypeDef GPIO_InitStructure;// Define a structure
// There are three parameters in the structure ,GPIO_Pin,GPIO_Speed and GPIO_Mode
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|
RCC_APB2Periph_GPIOE, ENABLE); // Turn on the clock
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; // 5 Pin is defined as input and output pin
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // It is defined as push-pull output mode
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // The input and output speed is 50MHz
GPIO_Init(GPIOB, &GPIO_InitStructure); // Initialize with the set parameters PB.5
GPIO_SetBits(GPIOB,GPIO_Pin_5); // yes PB5 Pin apply high level ,GPIO_ResetBits() Apply a low level to
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //
GPIO_Init(GPIOE, &GPIO_InitStructure); // initialization PE5
GPIO_SetBits(GPIOE,GPIO_Pin_5); //PE.5 Set to high
while(1)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_5);
GPIO_SetBits(GPIOE,GPIO_Pin_5);// meanwhile ,PB5 bright ,PE5 Exterminate
Delay(3000000);
GPIO_SetBits(GPIOB,GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_5);//
Delay(3000000);
}
}
To be continued
Technology