Legal code certificate in the XiaBuQu
Stm32 development board stm32__103VC
College students' practice of ultrasonic wave and the temperature and humidity test and the LCD display
Link: https://pan.baidu.com/s/1ry2yIM7TdJwBJ3eyqkYUNA extraction code: 6 CXX
Code to solve the thigh
CodePudding user response:
Single step, look at where the cardCodePudding user response:
In the concrete experiment programConcrete in PM=Jisuan_Juli () when no specific why not clear
CodePudding user response:
Jisuan_juli () aren't step into is, step to single, and the function of the source code posted, or else who knows where there is a problemCodePudding user response:
# include "the CSB. H"# include "ledkey. H"
# include "delay. H"
#include
# include "usartt. H"
# include "time3. H"
# include "timer. H"
Int overcount=0;
Void NVIC_Config (void)//ee??????? D?? O?? E??
{
NVIC_InitTypeDef NVIC_InitStructer;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitStructer. NVIC_IRQChannelPreemptionPriority=0;
NVIC_InitStructer. NVIC_IRQChannelSubPriority=0;
NVIC_InitStructer. NVIC_IRQChannel=TIM4_IRQn;
NVIC_InitStructer. NVIC_IRQChannelCmd=ENABLE;
NVIC_Init (& amp; NVIC_InitStructer);
}
Void CH_SR04_Init (void)//3? E?? ˉ? On? E mu? GPIOoiTIM4?? E +? Present
{
GPIO_InitTypeDef GPIO_InitStructer;
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructer;
RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOA, ENABLE);
//RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM4, ENABLE);
GPIO_InitStructer. GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStructer. GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructer. GPIO_Pin=GPIO_Pin_5;
GPIO_Init (GPIOA, & amp; GPIO_InitStructer);
GPIO_InitStructer. GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_InitStructer. GPIO_Pin=GPIO_Pin_6;
GPIO_Init (GPIOA, & amp; GPIO_InitStructer);
GPIO_ResetBits (GPIOA, GPIO_Pin_5);
GPIO_ResetBits (GPIOA, GPIO_Pin_6);
//TIM_DeInit (TIM4);
RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM4, ENABLE);//TIM41o mu? APB1
TIM_TimeBaseInitStructer. TIM_Period=1000-1;
TIM_TimeBaseInitStructer. TIM_Prescaler=72-1;
TIM_TimeBaseInitStructer. TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInitStructer. TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInit (TIM4, & amp; TIM_TimeBaseInitStructer);
TIM_ITConfig (TIM4, TIM_IT_Update, ENABLE);
NVIC_Config ();
TIM_SetCounter (TIM4, 0);//?? A?
TIM_Cmd (TIM4, DISABLE);
}
Float Jisuan_Juli (void)
{
Float length=0, sum=0;
U32 Tim;
Int I=0;
While (I!=5)//?????? '? 2 aa?????? U? Mu
{
GPIO_SetBits (GPIOA, GPIO_Pin_5);
Delay_us (20);
//Delay_us (20);
GPIO_ResetBits (GPIOA, GPIO_Pin_5);//ResetBits
//printf (" 123 ");
While (GPIO_ReadInputDataBit (GPIOA, GPIO_Pin_6)==0).
TIM_Cmd (TIM4, ENABLE);//ENABLE
//printf (" k ");
//overcount=0;
While (GPIO_ReadInputDataBit (GPIOA, GPIO_Pin_6)==1);
TIM_Cmd (TIM4, DISABLE);//DISABL
//printf (" g ");
Tim=TIM_GetCounter (TIM4);
//printf (" TIM=% d \ n ", TIM);
Length=(Tim + overcount * 1000)/58.8;
Sum=length + sum;
TIM_SetCounter (TIM4, 0);
//TIM4 - & gt; CNT=0;//TIM4?? Ey? Present?? A?
Overcount=0;//? D?? O? 3? '? Ey???? A?
i++;
Delay_ms (10);
}
Length=sum/5;
//printf (" % fa?? X \ n ", length);
Return length;
}
Void TIM4_IRQHandler (void)
{
If (TIM_GetITStatus (TIM4, TIM_IT_Update)!=RESET)
{
TIM_ClearITPendingBit (TIM4, TIM_IT_Update);
Overcount++;
}
}