Esempio n. 1
0
/* **********************************************************************
*      Function Name:  WriteUART                                       *
*      Return Value:   void                                            *
*      Parameters:     data: byte to send out the UART                 *
*      Description:    This routine sends a byte out the TXD pin.      *
*      Special Note:   The user must provide a routine:                * 
*                      DelayTXBit():                                   *
*                        DelayTXBit should have:                       *
*                              8 Tcy for overhead                      *
*                              2 Tcy call to DelayTXBit                *
*                              ? Tcy                                   *
*                              2 Tcy for return from DelayTXBit        *
*                      = (((2*OSC_FREQ)/(4*BAUDRATE))+1)/2  Tcy        *
*********************************************************************** */
void putch__(unsigned char uartdata)
//void WriteUART (unsigned char uartdata)
	{
	unsigned char bitcount=8,data;
	SW_TX=0;
	DelayTXBitUART();
	DelayTXBitUART();	
	DelayTXBitUART();	
	while (bitcount--)
		{
		//SW_TX=((uartdata>>=1) & 0x01);
		data=(uartdata & 0x01);
		uartdata>>=1;
		if(!data)
			SW_TX=0;
		else
			SW_TX=1;
		DelayTXBitUART();
		DelayTXBitUART();	
		DelayTXBitUART();	
		}
	SW_TX=1;
	DelayTXBitUART();
	DelayTXBitUART();	
	DelayTXBitUART();	
	}
Esempio n. 2
0
void putch(char c) {

    unsigned char bitcount = 8;

    //start
    sGPIO.GP1 = 0;   // falling edge means "start bit"
    GPIO = sGPIO.port;
    DelayTXBitUART();

    while (bitcount--) {
        sGPIO.GP1 = (c & 0x01);
        GPIO = sGPIO.port;
        DelayTXBitUART();
        c>>=1;
    }
    //stop
    sGPIO.GP1 = 1;   // go back to "holding pattern of "high"
    GPIO = sGPIO.port;
    DelayTXBitUART();

}