/*******************************************************************************
* Function Name  : Adc_Init
* Description    : Adc_Init
* Input          : none
* Output         : None
* Return         : none
*******************************************************************************/
void Adc_Init(void)
{
    Adc_DMA_Config();
	Adc_GPIOConfig();
	Adc_Config();
    
}
Exemple #2
0
uint16_t Adc_GetVoltage(void)
{
  uint16_t AdcValue = 0x00;
  uint16_t AdcSum   = 0x00;
  uint16_t Value    = 0x00;
  uint16_t AdcH     = 0x00;
  uint8_t i;

  
  for(i=0; i<5; i++)
  {
    Adc_Config();               //ADC单次触发配置
    while(!(ADCCON1 & 0x80));   //等待转换完成
    AdcValue  = ADCL >> 2;   
    AdcH      = ADCH;   
    AdcValue |= (AdcH << 6);
    AdcSum += AdcValue; 
    AdcH      = 0x00;
  }
  
  Value = AdcSum/5;
  
  return Value;
}
Exemple #3
0
//=============================================================================
void APP_MAIN(void)
{
	DI();
	DelayMS(400);
	
	Port_Config();		// HW config.
	Adc_Config();

	DelayMS(40); 		//30MS

	Sys_Interrupt_Config();

	Remo_Initial_Setting();

//=====================================
	EI();
	Condition_Ram_Initial();
//==================================
	DelayMS(500);
	Initial_Ram();
	
	Read_Backup_Data_From_EEPROM(READ_NONE);
	Micom_Comm_init();
	Micom_Comm_Receive_Start_F = 0;
	VolumeStepSetting();

	Port_Config();		// HW config.
	HALT();
	DelayMS(500);
	System.PowerOnOffDispReqF	= 0;
	Micom_Update_Display_Done();
	RC522_init_all();
//=====================================
	while(1)
	{
		On_Polling();
		
		if( Timer.b1ms )
		{
			Timer.b1ms = false;
			Timer_Manage();
			On_1msPolling();
		}
		/*if( Timer.b5ms )
		{
			Timer.b5ms = false;
			On_5msPolling();
		}*/
		if( Timer.b10ms )
		{
			Timer.b10ms = false;
			On_10msPolling();
		}
		/*if( Timer.b20ms )
		{
			Timer.b20ms = false;
			On_20msPolling();
		}
		if( Timer.b40ms )
		{
			Timer.b40ms = false;
			On_40msPolling();
		}
		if( Timer.b50ms )
		{
			Timer.b50ms = false;
			On_50msPolling();
		}
		if( Timer.b80ms )
		{
			Timer.b80ms = false;
			On_80msPolling();
		}*/
		if( Timer.b100ms )
		{
			Timer.b100ms = false;
			On_100msPolling();
		}
		if( Timer.b160ms )
		{
			Timer.b160ms = false;
			On_160msPolling();
		}
		/*if( Timer.b320ms )
		{
			Timer.b320ms = false;
			On_320msPolling();
		}
		if( Timer.b500ms )
		{
			Timer.b500ms = false;
			On_500msPolling();
		}
		if( Timer.b1000ms )
		{
			Timer.b1000ms = false;
			On_1000msPolling();
		}*/
	}
}