示例#1
1
void main(void)
{
// main entry point
_DISABLE_COP();

/********************************************************************/
// initializations
/********************************************************************/
 IIC0_Init();

	for (;;)
	{
	   WriteDAC(0b00100000,0b00110000,0x0FFF);	
	}

}
示例#2
0
文件: main.c 项目: zoreji/Portfolio
void main(void)
{
// main entry point
_DISABLE_COP();

/********************************************************************/
// initializations
/********************************************************************/
 SevSeg_Init();
 SevSeg_ButtInit();

	for (;;)
	{
	 // PART ONE
	 // 0b00001000 for left   (LED = 0b10000000) RED
	 // 0b00000001 for middle (LED = 0b01000000) YELLOW
	 // 0b00000010 for right  (LED = 0b00100000) GREEN
  
   // PT1AD1 = 0b00000000;
  	
	 //if (PT1AD1 & 0b00000010)
	 //  PT1AD1 |= 0b00100000;
	 //if (PT1AD1 & 0b00000001)
	 //  PT1AD1 |= 0b01000000;
	 //if (PT1AD1 & 0b00001000)
	 //  PT1AD1 |= 0b10000000;
	
	
	 // PART TWO

	 // if (PT1AD1 & 0b00001000)
	 //   PT1AD1 = 0b10000000;
	 // if (PT1AD1 & 0b00000010)
	 //   PT1AD1 = 0b00100000;
	 
	 
	 // PART THREE
	 // if (P_Debounce())
	 //   {
	 //     count++;
	 //     while (PT1AD1 & 0b00001000);
	 //   }
	 // else if (PT1AD1 & 0b00000001)
	 //   count = 0;
	 // SevSeg_Top4Hex(count);
	 
	 
	 // PART FOUR
	 // if (R_Debounce())
	 //   count++;
	 // if (PT1AD1 & 0b00000001)
	 //   {
	 //     while (PT1AD1 & 0b00001000);
	 //     if (PT1AD1 & 0b00000001)
	 //       count = 0;
	 //   }
	 // SevSeg_Top4Hex(count);
	}

}
示例#3
0
文件: main.c 项目: zoreji/Portfolio
void main(void) 	// main entry point
{
	_DISABLE_COP();

/********************************************************************
*		Initializations
********************************************************************/

SCI0_Init19200();	//19200 baud, 8-bit, 1 stop, no parity, no interrupts

	for (;;)		//endless program loop
	{
/********************************************************************
*		Main Program Code
********************************************************************/

		while(cYes == 'Y')
		{
			cInChar=0;						//NULL initialization for incoming ASCII character
			SCI0_TxString(cClearScreen);	//clean up display
			SCI0_TxString(cStartString);	//display title
			
			SCI0_TxString(cStringA);		//display prompt for first character
			while((cInChar<0x2F)||(cInChar>0x3A))	cInChar=SCI0_RxChar();	//wait for a valid input response
			SCI0_TxChar(cInChar);			//echo valid first character to the screen, beside the prompt
			cSum=ASCIIToHex(cInChar);		//convert to hex, move to hexadecimal summing variable
			 
			cInChar=0;						//NULL incoming ASCII character
			SCI0_TxString(cStringB);		//display prompt for second character
			while((cInChar<0x2F)||(cInChar>0x3A))	cInChar=SCI0_RxChar();	//wait for a valid input response
			SCI0_TxChar(cInChar);			//echo valid second character to screen, beside the prompt
			cSum+=ASCIIToHex(cInChar);		//convert to hex, add to hexadecimal summing variable
			
			SCI0_TxString(cStringX);		//display prompt for result
			cSum=(char)(HexToBCD(cSum));	//convert hexadecimal sum to BCD (cast into a char from int)
			cOut=HexToASCII(cSum>>4);		//prep first of two digits for display
			if(cOut=='0') cOut=' ';			//no leading zero
			SCI0_TxChar(cOut);				//send it out
			SCI0_TxChar(HexToASCII(cSum&0b11111111));	//display the second of two digits, converted to ASCII
			
			SCI0_TxString(cAgainString);	//display prompt for "Again?"
			cYes=0;							//NULL initialization for response
			while((cYes!='Y') && (cYes!='N')) cYes = (char)(SCI0_RxChar());	//wait for y or n converted to uppercase
			SCI0_TxChar(cYes);													//echo to screen
		}
		SCI0_TxString(cGoodbyeString);		//if "no", terminate the program after "goodbye"
		HALT
	}
}