大一,开始接触STM32开发板了
加入了实验室,实验室老师要求我们掌握嵌入式,听说学单片机嵌入式先学51单片机再学STM32更好,是吗
STM32单片机源程序如下:
- #include "stm32f4xx.h"
- #include "usart.h"
- #include "delay.h"
- int main(void)
- {
- u32 t=0;
- uart_init(115200);
- delay_init(84);
-
- while(1){
- printf("t:%d\r\n",t);
- delay_ms(500);
- t++;
- }
- }
- /*
- 手册中讲解到步骤15的时候的main.c源码如下:
- #include "stm32f4xx.h"
-
- void Delay(__IO uint32_t nCount);
- void Delay(__IO uint32_t nCount)
- {
- while(nCount--){}
- }
- int main(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
- GPIO_Init(GPIOF, &GPIO_InitStructure);
- while(1){
- GPIO_SetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
- Delay(0x7FFFFF);
- GPIO_ResetBits(GPIOF,GPIO_Pin_9|GPIO_Pin_10);
- Delay(0x7FFFFF);
-
- }
- }
- */
复制代码
所有资料51hei提供下载:
实验0 Template工程模板.zip
(497.18 KB, 下载次数: 18)
|