|
CHSF103C8T6為國(guó)產(chǎn)32位單片機(jī),性能也挺好,可部分代替說(shuō)stm32F103C8T6。
本次程序?yàn)辄c(diǎn)亮led:
- //io引腳配置
- #include "led.h"
- //LED IO初始化
- void LED_Init(void)
- {
-
- GPIO_InitTypeDef GPIO_InitStructure;
-
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); //使能PB,PE端口時(shí)鐘
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; //LED0-->PB.5 端口配置
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽輸出
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度為50MHz
- GPIO_Init(GPIOC, &GPIO_InitStructure); //根據(jù)設(shè)定參數(shù)初始化GPIOB.5
- GPIO_SetBits(GPIOC,GPIO_Pin_13); //PB.5 輸出高
- }
- #include "delay.h"
- #include "sys.h"
- #include "led.h"
- #include "timer.h"
- int main(void)
- {
- u16 t;
- delay_init();
- LED_Init();
- while(1)
- {
- LED0=0;
- delay_ms(1000);
- LED0=1;
- delay_ms(1000);
- }
- }
-
復(fù)制代碼
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); //使能PB,PE端口時(shí)鐘
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; //LED0-->PB.5 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽輸出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度為50MHz
GPIO_Init(GPIOC, &GPIO_InitStructure); //根據(jù)設(shè)定參數(shù)初始化GPIOB.5
GPIO_SetBits(GPIOC,GPIO_Pin_13); //PB.5 輸出高
}
|
|