Exemplo n.º 1
0
//  Subroutines Section
int main(void){
  PortB_Init();        								// Initialize microcontroller ports
  PortE_Init();	
 	PortF_Init();
	while(1){
		SW2 = GPIO_PORTF_DATA_R&0x01;			// Defines on-board button as SW2

		if(SW2 == 0x00 && before == 0){		// If SW2 is pressed and wasn't pressed in 
			if(count <= 9998){								// previous loop cycle. Prevents counter from
				count++;											// increasing when button is held down.
				before = 1;
			}
			else{														// Reset counter at 9999
				count = 0;
			}
		}
		
		if(SW2 == 0x01){									// If button isn't pressed
			before = 0;
		}
		
		NumSplit(count);									// Split value in counter into 4 numbers
		Display(1,digit1);								// Display number for lowest digit
		Display(2,digit2);			
		Display(4,digit3);
		Display(8,digit4);					
  }
}
Exemplo n.º 2
0
void encoderInit(int32_t *newArray) {
    position = newArray;

    PortA_Init();
    PortB_Init();
    PortD_Init();
    PortE_Init();
}
Exemplo n.º 3
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  PLL_Init(); 
	PortB_Init();
	//SysLoad(800000);
	SysFun();
  
  	// 80 MHz
   
	// initialize output and interrupts
  EnableInterrupts();
	/*Initialize ports and timers*/
  while(1){  
for(i=0;i<100;i++)
		{
GPIO_PORTB_DATA_R = (0x05); 
SysLoad(8000000); 

GPIO_PORTB_DATA_R = (0x06); 
SysLoad(8000000); 
	GPIO_PORTB_DATA_R = (0x0A); 
SysLoad(8000000); 

	GPIO_PORTB_DATA_R = (0x09); 
SysLoad(8000000); 
		}

SysLoad(80000000);

for(i=0;i<50;i++)
		{
GPIO_PORTB_DATA_R = (0x09); 
SysLoad(8000000); 
	GPIO_PORTB_DATA_R = (0x0A); 
SysLoad(8000000); 
		
GPIO_PORTB_DATA_R = (0x06); 
SysLoad(8000000); 
			
GPIO_PORTB_DATA_R = (0x05); 
SysLoad(8000000); 
		
		}
		
	
	




		/*Your code goes here*/
  }
}
int main(void){
  unsigned char input;
  PLL_Init();                      // Program 10.1
  SysTick_Init();                  // Program 10.2
  PortB_Init();                    // initialize motor outputs on Port B
  PortE_Init();                    // initialize sensor inputs on Port E
  cState = 0;                      // initial state = 0
  while(1){
    // output based on current state
    GPIO_PORTB_DATA_R = Fsm[cState].out; // step motor
    // wait for time according to state
    SysTick_Wait10ms(Fsm[cState].wait);
    // get input     
    input = GPIO_PORTE_DATA_R&0x03; // Input 0,1,2,3
    // change the state based on input and current state
    cState = Fsm[cState].next[input];
  }
}
Exemplo n.º 5
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  PLL_Init();  
	
  	// 80 MHz
   
	// initialize output and interrupts
  EnableInterrupts();
	 PortB_Init();/*Initialize ports and timers*/
	 SysTick_Init();
  while(1){   
  
		/*Your code goes here*/
		GPIO_PORTB_DATA_R=0X05;
		SysTick_Wait10ms(1);
		GPIO_PORTB_DATA_R=0X06;
		SysTick_Wait10ms(1);
		GPIO_PORTB_DATA_R=0X0A;
		SysTick_Wait10ms(1);
		GPIO_PORTB_DATA_R=0X09;
		SysTick_Wait10ms(1);
		
  }
}
int main(void){ 
	unsigned long volatile delay;	
  TExaS_Init(SW_PIN_PE210, LED_PIN_PB543210); // activate grader and set system clock to 80 MHz
	//TExaS_Scope();
  PortB_Init(delay);
	PortE_Init(delay);
	PortF_Init(delay);
	SysTick_Init();
  
  EnableInterrupts();
  while(1){
   
		outputB = fsm[S].outB;
		outputF = fsm[S].outF;
		SetOutputB(outputB);
		SetOutputF(outputF);
		SysTick_Wait_10ms(fsm[S].delay*10);
	
		
		input = GetInput();
		S = fsm[S].next[input];

  }
}
Exemplo n.º 7
0
// **************DAC_Init*********************
// Initialize 4-bit DAC 
// Input: none
// Output: none
void DAC_Init(void){
	PortB_Init();
}