EasyManuals Logo

Texas Instruments MSP430 User Manual

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #385 background imageLoading...
Page #385 background image
385
The header file also states the communication baud rate and number of bits:
#define baudrate 4800
#define no_of_bits 8
#define one_bit_delay (1000000 / baudrate)
#define half_bit_delay (one_bit_delay / 2)
Based on the baud rate further timing infos are calculated. Software UART is not as reliable as
hardware UART and so it is better to use low baud rates. It is even better if it can be skipped. However,
when there is no other option or when there is a need for additional UART, it must be used.
The UART transmit and receive functions are written using polling methods. External digital I/O
interrupt can be used for receiving data. These functions are created just by studying the signal
patterns and using the same tactics as with other software communication libraries. The trick is to
emulate/receive the signals as a real hardware would do.
void SW_UART_transmit(unsigned char value)
{
unsigned char bits = 0;
SW_UART_TXD_OUT_LOW();
delay_us(one_bit_delay);
for(bits = 0; bits < no_of_bits; bits++)
{
if((value >> bits) & 0x01)
{
SW_UART_TXD_OUT_HIGH();
}
else
{
SW_UART_TXD_OUT_LOW();
}
delay_us(one_bit_delay);
};
SW_UART_TXD_OUT_HIGH();
delay_us(one_bit_delay);
}
unsigned char SW_UART_receive(void)
{
unsigned char bits = 0;
unsigned char value = 0;
while(SW_UART_RXD_INPUT());
delay_us(one_bit_delay);
delay_us(half_bit_delay);
for(bits = 0; bits < no_of_bits; bits++)
{
if(SW_UART_RXD_INPUT())
{
value += (1 << bits);
}

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals