int main(void)
{
	
	bool ReadValue;
  /* 配置系统时钟为72M */
	SystemInit();
 
	/* TIM1 PWM波输出初始化,并使能TIM1 PWM输出 */
  //飞机起飞,飞到扔球区扔球,扔球,回到抓球区,等待PC发出指令,两个减速电机开始转动,共用3路pwm
	
	
//	TIM1_PWM_Init();                 //四路都开始输出pwm
 TIM1_PWM_Init();
	
	/*PB12 PB13分别连接两个行程开关,
	等滚子位置到达装球盒子边缘时
	任意一个行程开关发生碰撞进入中断就将两个减速电机停下
	*/
	
	EXTI_PB12_Config();
 EXTI_PB13_Config();	
	
	USART2_Configuration();
	
	key_init();
	
  while (1)
  {
	//	ReadValue = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_12);
		
		//USART_ReceiveData(USART2);
	//	USART_SendData(USART2, ReadValue);
}
//		return 0;
}
void SVPWM_3ShuntInit(void)
{
	TIM1_PWM_Init( );//TIM1 初始化
	CurrentReading_ADC_Init( );//ADC初始化
	SVPWM_3ShuntCurrentReadingCalibration( );//标定偏置电压
	TIM1_ADC_NVIC_Init( );	//ADC_TIM1中断初始化
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: reveriel/uCOS
int main(void)
{

	int i = 100000000;
	int j = 10000000;
	int  cnt = 1000;
	delay_init();

	led_Configuration();
	MPU6050_Configuration();
//	PWM_Configuration();
	TIM3_PWM_Init();
	TIM1_PWM_Init();
	TIM2_PWM_Init();
	
//	SysTick_Config(SystemCoreClock / 1000); // ms
	
	CtrData = CTRL_UP;
	
	while (i-- > 0) {
		while (j-- > 0) {
			;
		}
	}
	while (1) {
		
		
		if(schedulercnt_2ms >= 2)
		{	 
			if (cnt > 0)
			{
				//读加速度计和陀螺仪数据
				READ_MPU6050();
					//飞控函数
				Control();
				//PWM波输出函数
				PWMControl(PWM);
				cnt--;
			}
			else {
				CtrData = CTRL_STOP;
				Control();
				PWMControl(PWM);
				
			}
			
		schedulercnt_2ms = 0;
	    }
		

		
	}
	
}
Exemplo n.º 4
0
void Steering_Init(void) {
    STMFLASH_Read(STEERING_DATA_ADDR, (u16*)(&steering_data), sizeof(struct steering_type));
    TIM2_PWM_Init(20000,71);
    TIM3_PWM_Init(20000,71);
    TIM5_PWM_Init(20000,71);
    TIM1_PWM_Init(20000,71);
    TIM8_PWM_Init(20000,71);
    TIM4_PWM_Init(20000,71);
    if(STEERING_INIT_MARK==steering_data.mark)
        Steering_Move(steering_data.init);
    else
        Steering_Move(default_init);
}
Exemplo n.º 5
0
 int main(void)
 {	
	u16 led0pwmval=0;    
	u8 dir=1;	
	delay_init();	    	 //延时函数初始化	  
	LED_Init();		  	//初始化与LED连接的硬件接口
	TIM1_PWM_Init(899,0);//不分频。PWM频率=72000/(899+1)=80Khz 
   	while(1)
	{
 		delay_ms(10);	 
		if(dir)led0pwmval++;
		else led0pwmval--;	 
 		if(led0pwmval>300)dir=0;
		if(led0pwmval==0)dir=1;	   					 
		TIM_SetCompare1(TIM1,led0pwmval);	   
	} 
}