新手上路
- 积分
- 30
- 金钱
- 30
- 注册时间
- 2018-3-27
- 在线时间
- 17 小时
|

楼主 |
发表于 2018-5-17 17:57:43
|
显示全部楼层
/¶¨ê±Æ÷3ÖD¶Ï·tÎñ3ìDò
void TIM3_CH2_Excnt_Init(u16 arr,u16 psc)
{
RCC->APB1ENR|=1<<1; //TIM3 ????
RCC->APB2ENR|=1<<2; //??PORTA??
GPIOA->CRL&=0X0FFFFFFF; //PA7 ??????
GPIOA->CRL|=0X80000000; //PA7 ??
GPIOA->ODR|=1<<7; //PA7 ??
TIM3->ARR=arr; //??????????
TIM3->PSC=psc; //????
TIM3->CCMR1|=1<<8; //CC2S=01 ????? IC2???TI2?
TIM3->CCMR1|=0<<12; //IC2F=0000 ??????? ???
TIM3->CCER|=1<<5; //CC1P=0 ?????
TIM3->SMCR|=6<<4; //????:?????????2(TI2FP2)
TIM3->SMCR|=7<<0; //??????1
TIM3->CR1|=1<<0; //?????,CEN=1
}
int main(void)
{
u32 oldcnt=0;
Stm32_Clock_Init(9); //??????
uart_init(72,9600); //??????9600
delay_init(72); //?????
TIM3_CH2_Excnt_Init(0X0F,0); //????,???0xffff
while(1)
{
delay_ms(1000);
if(oldcnt!=TIM3->CNT)
{
oldcnt=TIM3->CNT;
printf("cnt:%d\r\n",oldcnt);
}
}
}
现在这个程序就是反馈回来的数值不准,不知道那块出问题了,
这个只是显示计数值程序 |
|