int16_t main(void) { initOSC(); init_Ports(); while(1){//Main loop LEDR_LAT = 1; LEDG_LAT = 1; LEDB_LAT = 0; } }
void main(void){ StateType *Pt; unsigned char sensor; //Set pointer at STRAIGHT Pt = STRAIGHT; //Initialize PWM and Ports init_PWM( ); init_Ports( ); init_PJ7( ); EnableInterrupts; for(;;) { //Only run for 2 laps if(lapCount <= 2) { //Adjust motor every time interval if(adjustMotor == 1) { //Check PT0-PT2 for sensors sensor = PORTA & 0x05; //Move to next state via sensor input Pt = Pt->Next[sensor]; //Set motor output based on state PWMDTY3 = Pt->PWMduty3 ; PWMDTY1 = Pt->PWMduty1 ; //Reset adjust flag adjustMotor == 0; } } else { //Turn off motors PWME = 0x00; } } }
/************************************************************** * Name : periodic_tasks_init_SysDrvs * Description : Initialize needed system drivers (system elements) before start application * Parameters : none * Return : none * Critical/explanation : no **************************************************************/ void periodic_tasks_init_SysDrvs(void) { init_Ports(); TFC_InitADCs(); }