- 打卡等级:偶尔看看I
- 打卡总天数:10
- 最近打卡:2024-09-12 17:45:17
注册会员
- 积分
- 101
|
发表于 2023-12-9 10:27:40
|
显示全部楼层
#ifdef time0_enable
void Timer_config(void)
{
TIM_InitTypeDef TIM_InitStructure; //
TIM_InitStructure.TIM_Mode = TIM_16BitAutoReload; // TIM_16BitAutoReload,TIM_16Bit,TIM_8BitAutoReload,TIM_16BitAutoReloadNoMask
TIM_InitStructure.TIM_Polity = Polity_0; // Polity_0,Polity_1,Polity_2,Polity_3
TIM_InitStructure.TIM_Interrupt = ENABLE; // ENABLE DISABLE.
TIM_InitStructure.TIM_ClkSource = TIM_CLOCK_12T; // TIM_CLOCK_1T,TIM_CLOCK_12T,TIM_CLOCK_Ext
TIM_InitStructure.TIM_ClkOut = ENABLE; // ENABLE DISABLE
TIM_InitStructure.TIM_Value = 65536UL - (MAIN_Fosc / (50*12));
TIM_InitStructure.TIM_Run = ENABLE; // ENABLE DISABLE
Timer_Inilize(Timer0,&TIM_InitStructure); //Timer0 Timer0,Timer1,Timer2,Timer3,Timer4
}
#endif
void main()
{
P_SW2 |= 0x80; //扩展寄存器访问使能
P0M1 = 0x00; P0M0 = 0x00; //设置为推挽输出
P1M1 = 0x00; P1M0 = 0x04; //设置为准双向口,P12推挽输出
P2M1 = 0x00; P2M0 = 0x00; //设置为准双向口
P3M1 = 0x00; P3M0 = 0x20; //设置为准双向口,P35推挽输出
P4M1 = 0x00; P4M0 = 0x00; //设置为准双向口
P5M1 = 0x00; P5M0 = 0x00; //设置为准双向口
P6M1 = 0x00; P6M0 = 0x00; //设置为准双向口
P7M1 = 0x00; P7M0 = 0x00; //设置为准双向口
#ifdef time0_enable
Timer_config();//注释掉这一行 P3.5 就不跳了,稳定在vcc的电压。
EA = 1;
#endif
P35 = 1;
while (1)
{
delay();
}
}
|
|