Serial Communications Interface (SCI)

This chapter describes the features and operation of the serial communication interface (SCI) module. SCI is a two−wire asynchronous serial port, commonly known as a UART. The SCI modules support digital communications between the CPU and other asynchronous peripherals that use the standard non-return to- zero (NRZ) format. The SCI receiver and transmitter each have a 16-level deep FIFO for reducing servicing overhead, and each has its own separate enable and interrupt bits. Both can be operated independently for half-duplex communication, or simultaneously for full-duplex communication.

To specify data integrity, the SCI checks received data for break detection, parity, overrun and framing errors. The bit rate is programmable to different speeds through a 16-bit baud-select register.

Features of the SCI module include:

• Two external pins:

– SCITXD: SCI transmit-output pin

– SCIRXD: SCI receive-input pin

Both pins can be used as GPIO if not used for SCI.

• Baud rate programmable to 64K different rates

• Data-word format

– One start bit

– Data-word length programmable from one to eight bits

– Optional even/odd/no parity bit

– One or two stop bits

– An extra bit to distinguish addresses from data (address bit mode only)

• Four error-detection flags: parity, overrun, framing, and break detection

• Two wake-up multiprocessor modes: idle-line and address bit

• Half- or full-duplex operation

• Double-buffered receive and transmit functions

• Transmitter and receiver operations can be accomplished through interrupt-driven or polled algorithms

with status flags.

• Separate enable bits for transmitter and receiver interrupts (except BRKDT)

• NRZ (non-return-to-zero) format

Figure 19-2. Serial Communications Interface (SCI) Module Block Diagram

Architecture

The major elements used in the full-duplex operation are shown in Figure 19-2 and include:

• A transmitter (TX) and its major registers (upper half of Figure 19-2)

– SCITXBUF — transmitter data buffer register. Contains data (loaded by the CPU) to be transmitted

– TXSHF register — transmitter shift register. Accepts data from registered SCITXBUF and shifts data

onto the SCITXD pin, one bit at a time

• A receiver (RX) and its major registers (lower half of Figure 19-2)

– RXSHF register — receiver shift register. Shifts data in from SCIRXD pin, one bit at a time

– SCIRXBUF — receiver data buffer register. Contains data to be read by the CPU. Data from a remote processor is loaded into register RXSHF and then into registers SCIRXBUF and SCIRXEMU

• A programmable baud generator

• Control and status registers

The SCI receiver and transmitter can operate either independently or simultaneously.

SCI Module Signal Summary

SCI Programmable Data Format

SCI data, both receive and transmit, is in NRZ (non-return-to-zero) format. The NRZ data format, shown in Figure 19-3, consists of:

• One start bit

• One to eight data bits

• An even/odd parity bit (optional)

• One or two stop bits

An extra bit to distinguish addresses from data (address-bit mode only)The basic unit of data is called a character and is one to eight bits in length. Each character of data is formatted with a start bit, one or two stop bits, and optional parity and address bits. A character of data with its formatting information is called a frame and is shown in Figure 19-3.

To program the data format, use the SCICCR register. The bits used to program the data format are shown in Table 19-2.

SCI Baud Rate Calculations

The internally generated serial clock is determined by the low-speed peripheral clock LSPCLK) and the baud-select registers. The SCI uses the 16-bit value of the baud-select registers to select one of the 64K different serial clock rates possible for a given LSPCLK.

See the bit descriptions in the baud-select registers, for the formula to use when calculating the SCI asynchronous baud. Table 19-3 shows the baud-select values for common SCI bit rates.

Bill of Materials

SCIA serial communication configuration steps

S.NoComponent NameDescriptionquantitylink
1LAUNCHXL-F28379DTTexas Instruments LAUNCHXL-F28379D1https://www.mouser.in/ProductDetail/Texas-Instruments/LAUNCHXL-F28379D?qs=8%252Br4Hz5Xir%252BwQNYYjOfeVA%3D%3D&gclid=CjwKCAjw-sqKBhBjEiwAVaQ9a3oGCM4lv5aWarWL_PFom-r9ueU4c2BPGSOO8TVxb4NSeAckouWnvxoCQzAQAvD_BwE
2USB TO UARTUSB TO UART TTL 5V 3.3V FT232RL1https://robu.in/product/ft232rl-usb-to-ttl-5v-3-3v-download-cable-to-serial-adapter-module-for-arduino/?gclid=CjwKCAjw-sqKBhBjEiwAVaQ9a4Z6Sx3byFQQOn4V1qdzWwttqDLxtvT8nNsl3QFFQ1-vUbEk94347RoChhAQAvD_BwE
BreadboardBreadboard1https://www.amazon.in/Electronicspices-Point-Solderless-Breadboard-Prototype/dp/B08YX57FJG/ref=asc_df_B08YX57FJG/?tag=googleshopdes-21&linkCode=df0&hvadid=396988870302&hvpos=&hvnetw=g&hvrand=4340047127636285617&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9302486&hvtargid=pla-1364897184161&psc=1&ext_vrnc=hi
3Male to Female Jumper WiresMale to Female Jumper Wires20https://www.flipkart.com/arduino-female-male-dupont-20cm-jumper-wire-40pcs-interconnect-electronic-hobby-kit/p/itmf8e5ezvkequ3h?pid=EHKF8DVBG9BXZHHH&lid=LSTEHKF8DVBG9BXZHHHQTDEHD&marketplace=FLIPKART&cmpid=content_electronic-hobby-kit_14498130132_u_8965229628_gmc_pla&tgi=sem,1,G,11214002,u,,,543116155366,,,,c,,,,,,,&ef_id=CjwKCAjw-sqKBhBjEiwAVaQ9a78ilC6dQUyT4nfLesr3KSgu64bQAoZiHfw4NxjPPpbPmw4YVNqlwhoCGIkQAvD_BwE:G:s&s_kwcid=AL!739!3!543116155366!!!u!297659526158!&gclid=CjwKCAjw-sqKBhBjEiwAVaQ9a78ilC6dQUyT4nfLesr3KSgu64bQAoZiHfw4NxjPPpbPmw4YVNqlwhoCGIkQAvD_BwE&gclsrc=aw.ds

1.1 Initialization SCIA corresponds to GPIO (Method_1)

void UART_GPIO_init(){

        //SCIB -> SCI0 Pinmux
         GPIO_setPinConfig(GPIO_43_SCIRXDA);
         GPIO_setPinConfig(GPIO_42_SCITXDA);

}

1. 1.1 Initialization SCIA corresponds to GPIO (Method_2)

void UART_GPIO_init(){
		

        // GPIO43 is the SCI Rx pin.
        //
        GPIO_setMasterCore(DEVICE_GPIO_PIN_SCIRXDA, GPIO_CORE_CPU1);
        GPIO_setPinConfig(DEVICE_GPIO_CFG_SCIRXDA);
        GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_DIR_MODE_IN);
        GPIO_setPadConfig(DEVICE_GPIO_PIN_SCIRXDA, GPIO_PIN_TYPE_STD);
        GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCIRXDA, GPIO_QUAL_ASYNC);

        //
        // GPIO42 is the SCI Tx pin.
        //
        GPIO_setMasterCore(DEVICE_GPIO_PIN_SCITXDA, GPIO_CORE_CPU1);
        GPIO_setPinConfig(DEVICE_GPIO_CFG_SCITXDA);
        GPIO_setDirectionMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_DIR_MODE_OUT);
        GPIO_setPadConfig(DEVICE_GPIO_PIN_SCITXDA, GPIO_PIN_TYPE_STD);
        GPIO_setQualificationMode(DEVICE_GPIO_PIN_SCITXDA, GPIO_QUAL_ASYNC);
}

1.2 Data format and Baud Rate


void SCI_A_init(){

    SCI_performSoftwareReset(SCIA_BASE);

       //
       // Configure SCIA for echoback.
       //
       SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |
                                                SCI_CONFIG_STOP_ONE |
                                                SCI_CONFIG_PAR_NONE));
       SCI_resetChannels(SCIA_BASE);
       SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT);
       SCI_enableModule(SCIA_BASE);
       SCI_performSoftwareReset(SCIA_BASE);

       //
       // Enable the TXRDY and RXRDY interrupts.
       //
       SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT);

   #ifdef AUTOBAUD
       //
       // Perform an autobaud lock.
       // SCI expects an 'a' or 'A' to lock the baud rate.
       //
       SCI_lockAutobaud(SCIA_BASE);
   #endif
}

Final Code

/*
 * main.c
 *
 *  Created on: Sep 28, 2021
 *      Author: devil
 */






#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "F28x_Project.h"
#include "F2837xD_device.h"
#include "F2837xD_Examples.h"

#include "device.h"
#include "driverlib.h"

#define    EMPTY_LOOP
#define    ENDLESS    1

void UART_GPIO_init();
void SCI_A_init();
void uart_tx_bite(uint16_t a);
void hal_PutsUART(char * s);
char tx_data = '0';

void main(void)
{
    Device_init();
    Device_initGPIO();
    UART_GPIO_init();
    SCI_A_init();

    while(1)
    {
        SCI_writeCharArray(SCIA_BASE, (uint16_t *)"MEVI HUB\r\n", sizeof("MEVI HUB\r\n"));
        DEVICE_DELAY_US(1000000);
    }
}




void UART_GPIO_init(){

        //SCIB -> SCI0 Pinmux
         GPIO_setPinConfig(GPIO_43_SCIRXDA);
         GPIO_setPinConfig(GPIO_42_SCITXDA);

}




void SCI_A_init(){

    SCI_performSoftwareReset(SCIA_BASE);

       //
       // Configure SCIA for echoback.
       //
       SCI_setConfig(SCIA_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |
                                                SCI_CONFIG_STOP_ONE |
                                                SCI_CONFIG_PAR_NONE));
       SCI_resetChannels(SCIA_BASE);
       SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT);
       SCI_enableModule(SCIA_BASE);
       SCI_performSoftwareReset(SCIA_BASE);

       //
       // Enable the TXRDY and RXRDY interrupts.
       //
       SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT);

   #ifdef AUTOBAUD
       //
       // Perform an autobaud lock.
       // SCI expects an 'a' or 'A' to lock the baud rate.
       //
       SCI_lockAutobaud(SCIA_BASE);
   #endif
}



Output

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: