예제 #1
0
//-----------------------SCI_OutSDec-----------------------
// Output a 16-bit number in signed decimal format
// Input: SCI port, 16-bit signed number to be transferred
// Output: none
// Variable format 2-6 digits with no space before or after
void SCI_OutSDec(unsigned char port, short n){
  if(n < 0){
    SCI_OutChar(port, '-'); /* negative */
    n = -n;
  }
  SCI_OutUDec(port, n);
}
예제 #2
0
//-----------------------SCI_OutUDec-----------------------
// Output a 16-bit number in unsigned decimal format
// Input: SCI port, 16-bit number to be transferred
// Output: none
// Variable format 1-5 digits with no space before or after
void SCI_OutUDec(unsigned char port, unsigned short n){
// This function uses recursion to convert decimal number
//   of unspecified length as an ASCI0I string 
  if(n >= 10){
    SCI_OutUDec(port, n/10);
    n = n%10;
  }
  SCI_OutChar(port, n+'0'); /* n is between 0 and 9 */
}
예제 #3
0
interrupt VectorNumber_Vtimch0 void ISR_Vtimch0(void){
  //int i;
  if (!(PTIT & (0x01))){            
    for(;;) {
        PTJ ^= 0x01;          // toggle LED     
        val1 = ATDDR0;       // read analog input from channel 11
        SCI_OutUDec(val1);    // output analog reading via serial
        OutCRLF();
        delayby1ms(3); 
    }    
    temp=TC0;   //refer back to TFFCA, we enabled FastFlagClear, thus by reading Timer Capture 
                //input we automatically clear the flag, allowing another TIC interrupt
  }
}