Ejemplo n.º 1
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  PLL_Init();  // 80 MHz 
	Port_Init();	
	ADC0_InitSWTriggerSeq3_Ch1();
	EnableInterrupts();
	SysFun();
	
	/*Initialize ports , ADC and timers*/
  while(1){   
		/*Your code goes here*/
		a= ADC0_InSeq3();
		t1=a+(10000/4096)+10000;
		in1=50;
		while(in1)
			{ 
GPIO_PORTA_DATA_R |= (0x20); 
SysLoad(t1); 
GPIO_PORTA_DATA_R &= ~(0x20); 
SysLoad(t-t1); 
in1=in1-1; 

}
			
	
	
  }
}
Ejemplo n.º 2
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
	
  PLL_Init();   
	
	
  	// 80 MHz
 
	
  EnableInterrupts();
	
	/*Initialize ports , ADC and timers*/
	ADC0_InitSWTriggerSeq3_Ch1();
	PortA_Init();
	
	//SysLoad(T);
	SysFun();
  while(1){   
		/*Your code goes here*/
		 value=ADC0_InSeq3();
		 //PWMindex=(ADCvalue);
		 p=((value+1)*390)+800000;
	//for(i=0;i<4;i++){

	 
GPIO_PORTA_DATA_R|=0x20;
SysLoad(p);	
GPIO_PORTA_DATA_R&=~0x20 ;
SysLoad(T-p);	
	//}
	
	
  }
}
Ejemplo n.º 3
0
// 3. Subroutines Section
// MAIN: Mandatory for a C Program to be executable
int main(void){
  PLL_Init();   
	Port_Init();
	ADC0_InitSWTriggerSeq3_Ch1();
	SysFun();
	
	 
	
  EnableInterrupts();
	
	/*Initialize ports , ADC and timers*/
  while(1){   
       SW = GPIO_PORTA_DATA_R&0x04;     // read PA2 into SW1
      if(SW){
GPIO_PORTA_DATA_R |=0x01; //PA0 HIGH
GPIO_PORTA_DATA_R&=~0x02; //PA1 LOW
} else
{
GPIO_PORTA_DATA_R |=0x02; //PA1 HIGH
GPIO_PORTA_DATA_R&=~0x01; //PA0 LOW
}

		 ADCvalue=ADC0_InSeq3();
		T1=TON+(ADCvalue *175);
	if (ADCvalue==0){
		GPIO_PORTA_DATA_R |=0x20;
		SysLoad(TON);
		GPIO_PORTA_DATA_R =~0x20;
		SysLoad(TON);
  }
else{
		GPIO_PORTA_DATA_R |=0x20;
		SysLoad(T1);
		GPIO_PORTA_DATA_R =~0x20;
		SysLoad(T-T1);
}
	}
}
// This initialization function sets up the ADC
// Max sample rate: <=125,000 samples/second
// SS3 triggering event: software trigger
// SS3 1st sample source:  channel 1
// SS3 interrupts: enabled but not promoted to controller
void ADC0_Init(void) {
    ADC0_InitSWTriggerSeq3_Ch1();
}