Beispiel #1
0
/*****************************************************************************
**   Main Function  main()
*****************************************************************************/
int main (void)
{	    		
  uint32_t counter = 0;

  /* SystemClockUpdate() updates the SystemFrequency variable */
  SystemClockUpdate();
  
  LPC_GPIO2->FIODIR = 0x000000FF;		/* P1.16..23 defined as Outputs */
  LPC_GPIO2->FIOCLR = 0x000000FF;		/* turn off all the LEDs */
    
  init_rit_timer( TIME_INTERVAL );		/* 10ms */	
  enable_rit_timer();

  while (1) 
  {					/* Loop forever */
	if ( rit_timer_counter >= (50 * counter) )	   // 0.5s
	{
	  LPC_GPIO2->FIOSET = 1 << counter;
	  counter++;
	  if ( counter > 8 )
	  {
		counter = 0;	
		rit_timer_counter = 0;
		LPC_GPIO2->FIOCLR = 0x000000FF;
	  }
	}
  }
}
Beispiel #2
0
int main(void)
{
	float SUPPLY_VOLTAGE = 3.3;    //en volts
	double ADC_COUNT_MAX = 4095;
	float ADC_STEP = SUPPLY_VOLTAGE/ADC_COUNT_MAX;

	//Update variable SystemCoreClock
	SystemCoreClockUpdate();
	#ifdef DEBUG
    	debug_printf("CPU Clock:%dMHz\n", SystemCoreClock/1000000);
    	debug_printf_flush();
	#endif

	// Enter an infinite loop, just incrementing a counter
	uint32_t count = 0;

	//Incializar RIT Timer
	init_rit_timer( TIME_INTERVAL );		/* 10ms */
	enable_rit_timer();

	int32_t variableA = 100;
	float variableB;
	float variableC;
	float variableD;
	float aux;
	int16_t i;

	while(1)
	{
		/*
		rit_timer_counter = 0;
		while( rit_timer_counter < 100000 )
		{
		}
		count++;
		*/

		rit_timer_counter = 0;
		for(i=0; i < 30000; i++)
		{
			aux = variableA*ADC_STEP;
			//variableB+=aux;
			//variableB += variableA*ADC_STEP;
			//variableC = aux*aux;
			//variableD += variableC;
		}
		int32_t tiempoFinal = rit_timer_counter;

		//#ifdef DEBUG
			//debug_printf("El valor de tiempoInical es: %d\n", tiempoInicial);
			debug_printf("El valor de tiempoFinal es: %d\n", tiempoFinal);
			//debug_printf("El valor de %d al cuadrado es: %d\n", variableA, variableB);
			//debug_printf("Interrupcion de Timer:%d \n", count);
			debug_printf_flush();
		//#endif
    }
	return 0;
}