This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: driverlib: Transmit-only SCI

Part Number: TMS320F28379D
Other Parts Discussed in Thread: LAUNCHXL-F28379D, , C2000WARE

Hello,

I want to implement some very basic logging over an UART. I try to base my implementation on the sci_ex2_loopback_interrupts.c example. The initialization sequence of the SCI peripheral starts with a call to SCI_setConfig() followed by a call to SCI_enableModule(). Unfortunately SCI_enableModule() unconditional enables the receiver and the transmitter. Even when I implement that register assignment within SCI_enableModule() on my own, I would also have to implement SCI_setConfig(), because the last step of SCI_setConfig() is also a call to SCI_enableModule().

Is there something I've overlooked? Any example for a vanilla logging UART using the driverlib?

best regards,

Torsten

  • Hi,

    Are you planning to implement the logging functionality without Receive? 

    Regards,

    Sudharsanan

  • Hi,

    yes, just transmitting data to a terminal for logging.

    best regards,

    Torsten

  • Hi Torsten,

    The LAUNCHXL-F28379D (Launchpad for the TMS320F28379D) has an out of box demo located in the directory below that will sample one of the ADC channels and output the results to a display in a serial terminal via UART/SCI. This might be a good example project to reference. You can modify the example to transmit what you want instead of the ADC sample readings.

    C:\ti\c2000\C2000Ware_version\device_support\f2837xd\examples\cpu1\launchxl_f28379d

    Let me know if this helps or if you have any questions.

    Best Regards,

    Marlyn

  • Hi Marlyn,

    that example doesn't make use of the driverlib. So I think it's not possible to implement a transmit-only UART using the driverlib. Thanks for responding!

    best regards,

    Torsten

  • Hi Torsten,

    I updated the code for the sci_ex2_loopback_interrupts.c example to implement a transmit-only UART (driverlib version).

    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    
    //
    // Globals
    //
    
    //
    // Send data for SCI-A
    //
    uint16_t sDataA[2];
    //
    // Function Prototypes
    //
    __interrupt void sciaTXFIFOISR(void);
    void initSCIAFIFO(void);
    
    //
    // Main
    //
    void main(void)
    {
        uint16_t i;
    
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Setup GPIO by disabling pin locks and enabling pullups
        //
        Device_initGPIO();
    
        //
        // Configuration for 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);
    
        //
        // Initialize PIE and clear PIE registers. Disables CPU interrupts.
        //
        Interrupt_initModule();
    
        //
        // Initialize the PIE vector table with pointers to the shell Interrupt
        // Service Routines (ISR).
        //
        Interrupt_initVectorTable();
    
        //
        // Interrupts that are used in this example are re-mapped to
        // ISR functions found within this file.
        //
        Interrupt_register(INT_SCIA_TX, sciaTXFIFOISR);
    
        //
        // Initialize the Device Peripherals:
        //
        initSCIAFIFO();
    
        //
        // Init the send data.  After each transmission this data
        // will be updated for the next transmission
        //
        for(i = 0; i < 2; i++)
        {
            sDataA[i] = i;
        }
    
        Interrupt_enable(INT_SCIA_TX);
    
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
    
        //
        // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
        //
        EINT;
        ERTM;
    
        //
        // IDLE loop. Just sit and loop forever (optional):
        //
        for(;;);
    }
    
    
    //
    // sciaTXFIFOISR - SCIA Transmit FIFO ISR
    //
    __interrupt void sciaTXFIFOISR(void)
    {
        uint16_t i;
    
        SCI_writeCharArray(SCIA_BASE, sDataA, 2);
    
        //
        // Increment send data for next cycle
        //
        for(i = 0; i < 2; i++)
        {
            sDataA[i] = (sDataA[i] + 1) & 0x00FF;
        }
    
        SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF);
    
        //
        // Issue PIE ACK
        //
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
    }
    
    //
    // initSCIAFIFO - Configure SCIA FIFO
    //
    void initSCIAFIFO()
    {
        //
        // Initialize SCIA and its FIFO.
        //
        SCI_performSoftwareReset(SCIA_BASE);
    
        //
        // 8 char bits, 1 stop bit, no parity. Baud rate is 9600.
        //
        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_resetTxFIFO(SCIA_BASE);
        SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_TXFF);
        SCI_enableFIFO(SCIA_BASE);
    
        //
        // TX FIFO Interrupts Enabled
        //
        SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXFF);
    
        SCI_enableModule(SCIA_BASE);
        SCI_performSoftwareReset(SCIA_BASE);
        SCI_resetTxFIFO(SCIA_BASE);
    
    #ifdef AUTOBAUD
        //
        // Perform an autobaud lock.
        // SCI expects an 'a' or 'A' to lock the baud rate.
        //
        SCI_lockAutobaud(SCIA_BASE);
    #endif
    }
    
    //
    // End of file
    //

    I changed the SCI_enableModule() function in the sci.h file to be:

    static inline void
    SCI_enableModule(uint32_t base)
    {
        //
        // Check the arguments.
        //
        ASSERT(SCI_isBaseValid(base));
    
        //
        // Enable TX, and the SCI.
        //
        HWREGH(base + SCI_O_CTL1) |= (SCI_CTL1_TXENA | SCI_CTL1_SWRESET);
        
        //
        // Enable RX, TX, and the SCI.
        //
        //HWREGH(base + SCI_O_CTL1) |= (SCI_CTL1_TXENA | SCI_CTL1_RXENA |
                                      //SCI_CTL1_SWRESET);
    }

    Hopefully it helps and is what you are looking for.

    Best Regards,

    Marlyn

  • Hi Maryln,

    thank you very much. I think I will just stick with my version that enables reception but doesn't use it. I'm a little bit to afraid of changing the library code. In case we have to update to a newer version, things will get too complicated.

    best regards,

    Torsten

  • Hi Torsten,

    That is a down-side to modifying the library-code. The code I provided should still work if you keep the SCI_enableModule() the same and like you said, enable reception just don't use it.

    Glad you found something that works for you!

    Best Regards,

    Marlyn