#include "iostm8L152k4.h"
main()
{
// 首先初始化GPIO
PD_DDR = 0x08;
PD_CR1 = 0x08; // 将PD3设置成推挽输出
PD_CR2 = 0x00;
// 然后初始化定时器4
TIM4_IER = 0x00;
TIM4_EGR = 0x01;
TIM4_PSCR = 0x07;
TIM4_ARR = 255;
TIM4_CNTR = 5;
TIM4_SR1 = 0x00;
TIM4_CR1 = 0x01;
while(1)
{
while((TIM4_SR1&0x01) == 0x00);
TIM4_SR1 = 0x00;
PD_ODR = PD_ODR ^ 0x08;
}
}
此帖出自
小平头技术问答
一周热门 更多>