⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于STM32的双极性逆变器软件
💻 C
字号:
/******************** 2.11.2010/holidays ********************
* File Name          : main.c
* Author             : MCD Application Team
* Version            : V2.0
* Date               : 02/11/2010
* DescriptWHY8W-QT9DJ-P0VNX-L15PE-W4DCR-VP3FMion        : Main program body
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x_lib.h"
#include "systm_init.h"
#include "PWM_adjust.h"
#include "uart.h"
#include "LCD_12864.h"
#include "adc.h"
#include "flash.h"
#include "PID.h"
#include "bitdef.h"
#include "key.h"
#include "adjust.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/


//******************************************************************************
extern unsigned char tim_flag,key_flag;
extern vu16 ADCConvertedValue[8];
extern u8 adc_flag;
extern unsigned char K1,K2;
extern u8 adjust_flag;
extern u16 set_I1,set_I2,set_v1;
u16 KG=300;
/*******************************************************************************
* Function Name  : main
* Description    : Main program.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{
  
  u8 N=0;
#ifdef DEBUG
    debug();
#endif
    
	//*****************flash***********************************
	//----------------------------------------------------------
	if(Flash_Read(StartAddr1)<=100&&Flash_Read(StartAddr1)>=1){
         K1=Flash_Read(StartAddr1);}	
      else{
         K1=K1;}
      if((Flash_Read(StartAddr2)&0x00ff)<=100&&(Flash_Read(StartAddr2)&0x00ff)>=1){
        K2=Flash_Read(StartAddr2);}
      else{
        K2=26;}
      
	  
		 
		 //***************************标量*********************
		 /*****************************************************


		 ******************************************************/	
	
	

	 //**********************系统初始化****************************
	  adjust(300);
	 Sys_Configuration();
	
	 // LED init
	 //--------------------------------------
	 //POUTB4=1;
	//GPIO_WriteBit(GPIOB, GPIO_Pin_6, (BitAction)0x00);
	  POUTB6=1;
	 //************************************************************
	  init_lcd ();
	 Serial_PutString("ADC test\r\n");
	 lcd_show_first ();
	  /*pid_int_tw();*/
	 	clrram ();
    /* Infinite loop */
    while (1)
    {
	  
	   switch(N++)
	   {
	   	 case 0: 
		        if(tim_flag)    {

				vol_show();
			 	tim_flag=0;
	              } break;
		 case 1: if(adc_flag){adc_deal();adc_flag=0;adjust_flag=1;} break;
		 case 2: if(key_flag){key_scan();key_flag=0;} break;
		 case 3: if(adjust_flag){adjust(KG);adjust_flag=0;}
		 default: POUTB6=!POUTB6;N=0;break;
	   
	   }  
    }
}

#ifdef  DEBUG
/*******************************************************************************
* Function Name  : assert_failed
* Description    : Reports the name of the source file and the source line number
*                  where the assert_param error has occurred.
* Input          : - file: pointer to the source file name
*                  - line: assert_param error line source number
* Output         : None
* Return         : None
*******************************************************************************/
void assert_failed(u8* file, u32 line)
{ 
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif

/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -