Exemple #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; 

}
			
	
	
  }
}
// 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);	
	//}
	
	
  }
}
Exemple #3
0
int main(void) {  PLL_Init();   
	SysFun();  // 80 MHz 
	PortA_Init() ; // initialize output and interrupts  
	EnableInterrupts(); 
	/*Initialize ports and timers*/  
	while(1){ 
unsigned long i,j;

for(i=80000; i<=160000; i+=16000)            /*on time starts from 1msec to 2msec with a increment of 0.2msec risein on tim */
		{
			for(j=0;j<4;j++)
			{
				GPIO_PORTA_DATA_R |= (0x40); 
				SysLoad(i); 
				GPIO_PORTA_DATA_R &= ~(0x40); 
				SysLoad(1600000-i);
			}
		}
for(i=160000; i>=80000; i-=16000)
		{
			for(j=0;j<4;j++)
			{
				GPIO_PORTA_DATA_R |= (0x40); 
				SysLoad(i); 
				GPIO_PORTA_DATA_R &= ~(0x40); 
				SysLoad(1600000-i);
			}
		}
  }
}
Exemple #4
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*/
  }
}
// 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);
}
	}
}