barsilikon.blogg.se

Serial communication protocol usb
Serial communication protocol usb








serial communication protocol usb

In our case ,all the bits in UCA0CTL0 are zero so we won't be configuring that register in our program.Ģ) UCAxCTL1 here UCA0CTL1 -The two important bits contained in this register are UCSSELx

serial communication protocol usb

Selecting between asynchronous(UART) and synchronous modes(SPI)

#SERIAL COMMUNICATION PROTOCOL USB SERIAL#

Number of stopbits ( here 1 so UCSPB = 0)Ģ bits used to select the asynchronous mode when UCSYNC = 0.Here we are using the default UART mode.Other modes are used with multiprocessor serial communication and for automatic baudrate detection Selects the character length 7/8 bit( we are using 8 bit so 0) Used for selecting between EVEN or ODD parity ( not used since we are disabling parity)Ĭontrols the direction of receive and transmit shift register (here LSB first) Used for enabling or disabling parity (In our case no parity so UCPEN = 0) ġ) UCAxCTL0 (USCI_Ax Control register0) here we are dealing with USC1_A0 so UCA0CTL0 -This register controls the settings for Parity selection,direction of data transmission(LSB or MSB first),character length,no of stop bits,modes of serial transmission. If (CALBC1_1MHZ = 0xFF) // If calibration constant erasedĭCOCTL = 0 // Select lowest DCOx and MODx settingsĭCOCTL = CALDCO_1MHZ // Set DCO step + modulationĬALBC1_1MHZ is a constant defined in the header file msp430g2553.h,inside the header file you can find the constants for configuring the DCO to operate at 1,8,12 and 6MHz ( CALBC1_1MHZ,CALBC1_8MHZ,CALBC1_12MHZ,CALBC1_16MHZ ).Īfter configuring the system clock to 1MHz, we are going to look into the registers and bits that are important for configuring the UART.Please note that only relevant registers and bits will be explained. Here I am going to configure the DCO to generate 1MHz and use SMCLK as UART clock.To generate accurate 1MHz clock I am going to load the caliberation constants into the Basic clock system register and DCO control registers like this In the above figure you can see that the USCI can source clock from either SMCLK or ACLK to generate BRCLK which is then used to generate the required timings.UC0CLK is external clock sourced from outside through MSP430 pins. In this example we are going to configure the MSP430 UART to transmit and receive at 9600bps with 8 databits,no Parity and 1 Stop bit. You can see the (very) simplified block diagram of USCI_A0 in UART mode below.

serial communication protocol usb

Asynchronous serial communication is widely used for communicating with external devices like PC/Laptops,GSM modems,GPS modules etc.It also forms the basis for many standard protocols like RS232, RS422, RS485 etc.

serial communication protocol usb

In this article we we will configure USCI_A0 in MSP430G2553 to handle asynchronous serial communication or commonly known as UART mode.The UART mode uses two pins to transmit ( UCA0TXD ​) and receive data( UCA0RXD​). USCI_A0 can be configured to handle LIN,IrDA,SPI and asynchronous serial communication (UART) while USCI_B0 can handle SPI and I2C. MSP430G2553 has two USCI modules names as USCI_A0 and USCI_B0 for handling multiple communication formats. The peripheral is designed in such a way that it can handle multiple serial communication formats ,synchronous as well as asynchronous like SPI, I2C,IrDA, UART etc. In MSP430, serial communication is handled by an on chip peripheral called USCI ( Universal Serial Communications Interface​).










Serial communication protocol usb