/*********************************************************************//**
 * @brief	Initial System Init using Port and Peripheral
 * @param[in]	None
 * @return 		None
 **********************************************************************/
void System_Init(void)
{
	LPC_WDT->WDMOD &= ~WDT_WDMOD_WDEN;  // Disable Watchdog
	SystemInit();						// Initialize system and update core clock
	Port_Init();                        // Port Initialization
	SYSTICK_Config();                   // Systick Initialization
	led_delay = 1000;                   // Heart Beat rate of 1Sec toggle
	NVIC_SetPriority(SysTick_IRQn, 0);  // Set SysTick as Highest Priority

	UART_Config(LPC_UART0, 115200);       // Uart0 Initialize at 9600 Baud Rate
	SSP_Config (LPC_SSP1);              // Initialize SPI
	I2C_Config (LPC_I2C0);              // Initialize I2C0
	GLCD_Init();                        // Initialize GLCD

	GPIO_IntCmd(2,_BIT(7),1);          // Enable GPIO Interrupt at P0.19 Falling Edge
	NVIC_EnableIRQ(EINT3_IRQn);         // NVIC Interrupt EINT3_IRQn for GPIO
	NVIC_SetPriority(EINT3_IRQn, 4);    // Set any lower Priority than SysTick

	TSC2004_Cal_Init(&cmatrix);

}
Beispiel #2
0
int main(void)
{
	GPIO_Config();
	SYSTICK_Config();
	LCD_Init();
	ADC_Config();
	USART_Config();
	DAC_Mode_Init();


	LCD_Clear(0, 0, 240, 320, BACKGROUND);
	LCD_DispStr(40, 60, (uint8_t*)"Iin_Base:", BLACK);
	LCD_DispStr(40, 90, (uint8_t*)"Iin_Phase:", BLACK);
	LCD_DispStr(40, 110, (uint8_t*)"Vin_Phase:", BLACK);
	LCD_DispStr(40, 140, (uint8_t*)"PF:", BLACK);
//	
//	Init_Iin(Iin);
//	Init_Vin(Vin);
//	
//	cr4_fft_256_stm32(Iin_FFT,Iin,NPT);
//	cr4_fft_256_stm32(Vin_FFT,Vin,NPT);
//	
//	GetPowerMag(Iin_Mag,Iin_FFT);
//	
//	BasePercent = GetBasePercent(Iin_Mag);
//	
//	Iin_Phase = GetPhase(Iin_FFT);
//	
//	Vin_Phase = GetPhase(Vin_FFT);
//	
//	PowerFactor = GetPFValue(BasePercent, Iin_Phase, Vin_Phase);
//	
//	LCD_DispADC(120, 60, BasePercent, BLACK);
//	LCD_DisNum(120, 90, (uint16_t)Iin_Phase, BLACK);
//	LCD_DisNum(120, 110, (uint16_t)Vin_Phase, BLACK);
//	LCD_DispADC(120, 140, PowerFactor, BLACK);
	
	while(1)
	{
		Vin_total=0;
		Iin_total=0;
		Iout_total=0;
		for(i=0;i<NPT;i++)
		{
				Vin[i]=ADCConvertedValue[i*5];
				//Vin_total+=Vin[i];
				Iin[i]=ADCConvertedValue[i*5+1];
				//Iin_total+=Iin[i];
				Iout[i]=ADCConvertedValue[i*5+2];
				//Iout_total+=Iout[i];
		}
//		Vin_total=Vin_total/256;
//		Iin_total=Iin_total/256;
//		Iout_total=Iout_total/256;		

//		LCD_DisNum(120, 90, Vin_total, BLACK);
//		LCD_DisNum(120, 110, Iin_total, BLACK);
//		LCD_DisNum(120, 130, Iout_total, BLACK);
		
	cr4_fft_256_stm32(Iin_FFT,Iin,NPT);
	cr4_fft_256_stm32(Vin_FFT,Vin,NPT);
	
	GetPowerMag(Iin_Mag,Iin_FFT);
	
	BasePercent = GetBasePercent(Iin_Mag);
	
	Iin_Phase = GetPhase(Iin_FFT);
	
	Vin_Phase = GetPhase(Vin_FFT);
	
	PowerFactor = GetPFValue(BasePercent, Iin_Phase, Vin_Phase);
	
	LCD_DispADC(120, 60, BasePercent, BLACK);
	LCD_DisNum(120, 90, (uint16_t)Iin_Phase, BLACK);
	LCD_DisNum(120, 110, (uint16_t)Vin_Phase, BLACK);
	LCD_DispADC(120, 140, PowerFactor, BLACK);
	
	
	
	}


}	//main