大一,開始接觸STM32開發板了
加入了實驗室,實驗室老師要求我們掌握嵌入式,聽說學單片機嵌入式先學51單片機再學STM32更好,是嗎
0.png (45.23 KB, 下載次數: 22)
下載附件
2018-5-26 17:28 上傳
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)
2018-5-26 14:08 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|