Exemple #1
0
int main(void)
{
	while(1)
	{
		resetCoreTimer();
		delay(1);
		printInt(readCoreTimer(), 10 + (10 << 16));
		printStr("\r\n");
	}
}
Exemple #2
0
int main(void){
    unsigned int i = 0;
    static const unsigned char codes[] = {0x4, 0x2, 0x1, 0x8, 0x10, 0x20, 0x40, 0x8};

    TRISB = TRISB & 0xFC00;                         // Configure TRISB bits 9-0 as Digital Output
    LATBbits.LATB9 = 1;                             // Turn On MSDisplay
    LATBbits.LATB8 = 0;
    
    while(1){
        resetCoreTimer();
        while(readCoreTimer() < 5000000);           // Wait 250ms (0.25 sec)
        LATB = (LATB & 0xFF00) | codes[i];          // Turn On Segment
        if(++i > 7) i = 0;                          // Reset Index
    }

    return 0;
}
Exemple #3
0
	int main(void){
	
	initPIC32();
	closedLoopControl( false );
		setVel2(0, 0); //Stop Engines


	int start, oldStart = 2;
	resetCoreTimer();
		while(1){
			start = startButton();
				if(start != oldStart)
					printf("%10d %d\n",readCoreTimer()/1000, start);

			oldStart = start;
		}
	return 0;

}
Exemple #4
0
int main (void)
{
	//iniciçao da pic
  	initPIC32 ();
  	closedLoopControl( true );
  	setVel2(0, 0);

  	T4CONbits.TCKPS=5;
PR4=(PBCLK/32/3)-1;//fout 20MHz/(32*(62499+1))*10Hz,freq a 1 hz
TMR4=0;//Reset timer T2
T4CONbits.TON=1;
//Interrupts
IFS0bits.T4IF=0;//reset do timer
IPC4bits.T4IP=2;//priority
IEC0bits.T4IE=1;//enable timer3
EnableInterrupts();

	printStr(__FILE__); // para saber o nome do ficheiro que esta a correr no robot
	printf("\r    battery: %d ", batteryVoltage());
	printStr("\n");
	

//desligar os leds para o inicio
	leds(0b1111);	//leds off


  #if 0

	while(1)
	{
		while(!tick40ms);
		tick40ms=0;
		readAnalogSensors();
		


	}


  #endif



  while (TRUE)
    {
	
	
	TimeOut();		// timeOut => tb devia ir para uma inturrupcao

	//Sensor(); 	 //leitura os sensores tem de se por numa interropecao

	


	//botao de estado 

	if(startButton() == 1) // Botao start(preto) primido
	{
		estado = 1;
		resetCoreTimer();
		leds(0x1);
	
	}
	else if(stopButton() == 1) //Botao stop(vermelho) primido
	{
		estado = 0;
		leds(0x0);
	}

 	//funcoa de funcionameneto
	if(estado == 1) // robot fica em presesamento
	{
		Ver_Farol();
		printf("D: %d   F: %d   E: %d     LINHA: %d    Farol: %d \r",	sensor_dir,sensor_frente,sensor_esq,linha ,farolsen );
		ANDAR2();
	}
	//quando e primido o botao stop
	else if(stopButton() == 1)		// deslica o funcionamento, nenhum led activo
	{
		
		Stop_robot();
	
	}

    }
  return (0);
}