Пример #1
0
//Initialize all the timers
void InitTimers(void)
{
    init_timer1();
    init_timer2();
    init_timer3();
    init_timer4();
    init_timer5();
}
Пример #2
0
void InitApp(void)
{
    /* Setup analog functionality and port direction */
    //IO configuration (pull-up CN interrupts enable


//    IEC1bits.CNIE=1;
//    IPC4bits.CNIP=1;


    /* Initialize peripherals */
    init_peripheral_pin_select();
    uart1_Initialize(19200);
    init_timer2();
    init_timer3();
    init_SPI1();
    init_SPI2();
}
Пример #3
0
void comm_init(unsigned char seed, unsigned char ID)
{
	int i;

	e_init_randb(I2C); // IR ring in I2C mode
	e_randb_set_range(0); // Transmit IR with full power (0xff is min power)
	e_randb_store_light_conditions(); // Calibrate background IR levels

	/* Pre-compute random values for communication backoff */
	srand(seed + TMR1);
	for (i = 0; i < RANDOM_BACKOFF_SIZE; i++)
		random_backoff[i] = rand() % MAX_SEND_TIMER_BACKOFF;

	tx_buffer.bits.ID = ID;
		
	init_timer3(); // Start broadcasting the contents of tx_buffer
		
	e_start_agendas_processing();
}
Пример #4
0
int main()
{
 stm32_NvicSetup ();
 Setup_Pll_As_Clock_System();
 init_portA();
 init_portB();
 init_portC();
 init_timer2();
 init_timer4();
 init_timer1();
 Setup_Adc();
 Adc_On();
 init_timer3();			
				// STM32 setup
 //GPIOA->ODR |=0x0020; 
 Recule_train_Arriere();
                        
while(1)
   { 
   }
}
Пример #5
0
int main(void)
{
	//lprintf("%d", 4);
	init_ADC();
	init_timer3();
	init_timer();
	init_USART(calcUBRR(BAUD));
	char * str = "Degrees\tIR Distance (cm)\tSonar Distance (cm)\n\n\r";
	move_servo(0);
	char degrees = 0;
    while(1)
    {
        //send_pulse();
		Transmit_String(str);
		sprintf(str, "%d\t%d\t%d\n\r", degrees, ir_distance(), time2dist(ping_read()));
		move_servo(degrees);
		degrees += 2;
		if(degrees > 180)
			break;
    }
}
Пример #6
0
Файл: Axon.c Проект: abarbu/axon
int main(void)
{
  /****************INITIALIZATIONS*******************/
  //other stuff Im experimenting with for SoR
  uartInit();  // initialize the UART (serial port)
  uartSetBaudRate(0, 9600); // set UARTE speed, for Bluetooth
  uartSetBaudRate(1, 115200); // set UARTD speed, for USB connection, up to 500k, try 115200 if it
  uartSetBaudRate(2, 57600); // set UARTH speed
  uartSetBaudRate(3, 57600); // set UARTJ speed, for Blackfin
  //G=Ground, T=Tx (connect to external Rx), R=Rx (connect to external Tx)

  // initialize rprintf system and configure uart1 (USB) for rprintf
  rprintfInit(uart1SendByte);

  configure_ports(); // configure which ports are analog, digital, etc.

  LED_on();

  rprintf("\r\nSystem Warming Up");

  // initialize the timer system (comment out ones you don't want)
  init_timer0(TIMER_CLK_1024);
  init_timer1(TIMER_CLK_64);
  init_timer2(TIMER2_CLK_64);
  init_timer3(TIMER_CLK_64);
  init_timer4(TIMER_CLK_64);
  init_timer5(TIMER_CLK_1024);
  //timer5Init();

  a2dInit(); // initialize analog to digital converter (ADC)
  a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
  a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage

  int i = 0, j = 0;
  //let system stabelize for X time
  for(i=0;i<16;i++)
  {
    j=a2dConvert8bit(i);//read each ADC once to get it working accurately
    delay_cycles(5000); //keep LED on long enough to see Axon reseting
    rprintf(".");
  }

  LED_off();

  rprintf("Initialization Complete \r\n");

  reset_timer0();
  reset_timer1();
  reset_timer2();
  reset_timer3();
  reset_timer4();
  reset_timer5();

  while(1)
  {
    control();
    delay_cycles(100);
    //an optional small delay to prevent crazy oscillations
  }

  return 0;
}
Пример #7
0
void prvSetupHardware(){

	int i, j;

	//add 1.7s delay for potential power issues
	delay_cycles(65535);
	delay_cycles(65535);
	delay_cycles(65535);
	delay_cycles(65535);
	delay_cycles(65535);
	delay_cycles(65535);
	delay_cycles(65535);
	
	

	uartInit();  // initialize the UART (serial port)
    uartSetBaudRate(0, 38400); // set UARTE speed, for Bluetooth
    uartSetBaudRate(1, 115200); // set UARTD speed, for USB connection, up to 500k, try 115200 if it doesn't work
    uartSetBaudRate(2, 38400); // set UARTH speed
    uartSetBaudRate(3, 38400); // set UARTJ speed, for Blackfin
	//G=Ground, T=Tx (connect to external Rx), R=Rx (connect to external Tx)

	rprintfInit(uart1SendByte);// initialize rprintf system and configure uart1 (USB) for rprintf

	configure_ports(); // configure which ports are analog, digital, etc.

	LED_on();

	//rprintf("\r\nSystem Warmed Up");

	// initialize the timer system
 	init_timer0(TIMER_CLK_1024);
// 	init_timer1(TIMER_CLK_64); // Timer 1 is initialized by FreeRTOS
 	init_timer2(TIMER2_CLK_64);
 	init_timer3(TIMER_CLK_64);
 	init_timer4(TIMER_CLK_64);
 	init_timer5(TIMER_CLK_64);

	a2dInit(); // initialize analog to digital converter (ADC)
	a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
	a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage

	//let system stabelize for X time
	for(i=0;i<16;i++)
		{
		j=a2dConvert8bit(i);//read each ADC once to get it working accurately
		delay_cycles(5000); //keep LED on long enough to see Axon reseting
		rprintf(".");
		}

	LED_off();

	rprintf("Initialization Complete \r\n");

	//reset all timers to zero
	reset_timer0();
	reset_timer1();
	reset_timer2();
	reset_timer3();
	reset_timer4();
	reset_timer5();



	/********PWM Setup***********/
	prvPWMSetup();

}