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.

TMS320F28377S: SCI communication

Part Number: TMS320F28377S
Other Parts Discussed in Thread: C2000WARE

Hi,

My customer is developing SCI communication code in their firmware, but it doesn't work.
Could you provide your advise to solve the problem?   The phenomena is described in below.

- F28377S communicates with other portion in the customer's system through SCI.

- F28377S send several packets to the other portion and receiver can receive the message.

- The receiver send packets to F28377S and RX pin waveform seems correct.  Then "H" level is about 3.3V and "L" level is about 0V.

- Their fimware can note detect interrupt for RX and F28377S can't receive the message from the receiver.

- When loop back mode is enabled, interrupt flag is asserted and F28377S can receive the message from the receiver.

I attached their code for related to register setting.  PLS see the attached temp.c file.
If you need more infromation to solve this, PLS let me know.

void init(void)
{

	InitSysCtrl();
	DINT;
	InitPieCtrl();
	IER = 0x0000;
	IFR = 0x0000;
	InitPieVectTable();
	initGpio();

	GPIO_SetupPinMux(	56	,	GPIO_MUX_CPU1	,	6	);	//CF�J�[�h����iTxD�j
	GPIO_SetupPinMux(	57	,	GPIO_MUX_CPU1	,	6	);	//CF�J�[�h����iRxD�j��
	GPIO_SetupPinOptions(	56	,	GPIO_OUTPUT	,	GPIO_ASYNC	);	//CF�J�[�h����iTxD�j
	GPIO_SetupPinOptions(	57	,	GPIO_INPUT	,	GPIO_PUSHPULL	);	//CF�J�[�h����iRxD�j��

	EALLOW;  // This is needed to write to EALLOW protected registers
	PieVectTable.SCIC_TX_INT			=	&scic_tx_isr;
	PieVectTable.SCIC_RX_INT			=	&scic_rx_isr;
	EDIS;    // This is needed to disable write to EALLOW protected registers

	ScicRegs.SCICCR.all					=	0x0007;		//8bit,Idle-line mode,no loop back,no parity,one stop bit
	ScicRegs.SCICTL1.all				=	0x0003;		//TX,RX enable, internal SCK clk,ERR,SLEEP,TXWAKE disable
	ScicRegs.SCICTL2.bit.TXINTENA		=	1;			//TX int disable
	ScicRegs.SCICTL2.bit.RXBKINTENA		=	1;			//RX int enable
	ScicRegs.SCIHBAUD.all				=	((uint16_t)CF_SCI_PRD  & 0xFF00U) >> 8U;
	ScicRegs.SCILBAUD.all				=	(uint16_t)CF_SCI_PRD  & 0x00FFU;
	ScicRegs.SCIFFTX.all				=	0xC022;		//TX���荞�݂�FIFO��15�ȉ��Ŕ���
	ScicRegs.SCIFFRX.all				=	0x0022;		//RX���荞�݂�FIFO��1�ȏ�Ŕ���
	ScicRegs.SCIFFCT.all = 0x00;

	ScicRegs.SCICTL1.all				=	0x0023;		//SCI�\�t�g�E�F�A���Z�b�g
	ScicRegs.SCIFFTX.bit.TXFIFORESET	=	1;			//TX FIFO���Z�b�g
	ScicRegs.SCIFFRX.bit.RXFIFORESET	=	1;			//RX FIFO���Z�b�g
	
	
	PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
	PieCtrlRegs.PIEIER8.bit.INTx5					=	1;
	PieCtrlRegs.PIEIER8.bit.INTx6					=	1;
	IER									|=	M_INT8;

	EnableInterrupts();

	EINT;
	ERTM;  // Enable Global realtime interrupt DBGM
}

Best Regards, Taki

  • Hi Taki,

    Thanks for your question! I do have one concern with the code attached in the original post, but will need a bit more of the source code to further debug. In particular, lines 12 to 15 have functions "GPIO_SetupPinMux" and "GPIO_SetupPinOptions". To make sure these work properly, can you provide the code for these functions if they have been changed from our C2000Ware example functions?

    Code snippet here:

    GPIO_SetupPinOptions(	56	,	GPIO_OUTPUT	,	GPIO_ASYNC	);
    GPIO_SetupPinOptions(	57	,	GPIO_INPUT	,	GPIO_PUSHPULL	);

    My concern is that GPIO_SetupPinOptions function seems to setup ASYNC and PUSHPULL, which are different settings on the chip.

    Making the GPIO qualification ASYNCHRONOUS is recommended for RX, but it is also recommended to have it as PUSH-PULL as well. These should both be set (as shown in the C2000Ware example below):

    // GPIO28 is the SCI Rx pin.
    //
    ... GPIO_setPadConfig(28, GPIO_PIN_TYPE_STD); //THIS SETS THE RX IN PUSH-PULL MODE GPIO_setQualificationMode(28, GPIO_QUAL_ASYNC); //THIS SETS THE RX QUALIFICATION AS ASYNCRHONOUS
    ...

    Please view C2000Ware example sci_ex1_loopback.c in "C2000Ware_#_##_##_##\f2837xs\examples\cpu1\sci\" for an in-depth look at our recommended initialization sequence.

    Let me know if you are able to provide these details for further debug!

    Regards,

    Vince

  • Hi,

    The functions, “GPIO_SetupPinMux" and "GPIO_SetupPinOptions", are not changed and F2837xS_Gpio.c, which is attached in this thread, is reffered. 

    The following code was tried to run based on your advice, but the issue was not solved.
                 GPIO_SetupPinOptions( 56         ,             GPIO_OUTPUT ,             GPIO_PUSHPULL|GPIO_ASYNC );
                 GPIO_SetupPinOptions( 57         ,             GPIO_INPUT     ,             GPIO_PUSHPULL|GPIO_ASYNC );

    The following example code was referred for coding.
      C2000Ware_2_01_00_00\device_support\f2837xs\examples\cpu1\sci_loopback_interrupts\cpu01
      Example_2837xSSci_FFDLB_int.c

    //###########################################################################
    //
    // FILE:    F2837xS_Gpio.c
    //
    // TITLE:    GPIO module support functions
    //
    //###########################################################################
    // $TI Release: F2837xS Support Library v3.09.00.00 $
    // $Release Date: Thu Mar 19 07:39:41 IST 2020 $
    // $Copyright:
    // Copyright (C) 2014-2020 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //###########################################################################
    
    //
    // Included Files
    //
    #include "F2837xS_device.h"
    #include "F2837xS_Examples.h"
    
    //
    // InitGpio - Sets all pins to be muxed to GPIO in input mode with pull-ups
    //            enabled. Also disables open drain and polarity inversion and sets
    //            the qualification to synchronous. Also unlocks all GPIOs
    //
    void InitGpio()
    {
        volatile Uint32 *gpioBaseAddr;
        Uint16 regOffset;
    
        //
        //Disable pin locks
        //
        EALLOW;
        GpioCtrlRegs.GPALOCK.all = 0x00000000;
        GpioCtrlRegs.GPBLOCK.all = 0x00000000;
        GpioCtrlRegs.GPCLOCK.all = 0x00000000;
        GpioCtrlRegs.GPDLOCK.all = 0x00000000;
        GpioCtrlRegs.GPELOCK.all = 0x00000000;
        GpioCtrlRegs.GPFLOCK.all = 0x00000000;
    
        //
        //Fill all registers with zeros. Writing to each register separately
        //for six GPIO modules would make this function *very* long. Fortunately,
        //we'd be writing them all with zeros anyway, so this saves a lot of space.
        //
        gpioBaseAddr = (Uint32 *)&GpioCtrlRegs;
        for (regOffset = 0; regOffset < sizeof(GpioCtrlRegs)/2; regOffset++)
        {
            //
            //Hack to avoid enabling pull-ups on all pins. GPyPUD is offset
            //0x0C in each register group of 0x40 words. Since this is a
            //32-bit pointer, the addresses must be divided by 2.
            //
            if (regOffset % (0x40/2) != (0x0C/2))
            {
                gpioBaseAddr[regOffset] = 0x00000000;
            }
        }
    
        gpioBaseAddr = (Uint32 *)&GpioDataRegs;
        for (regOffset = 0; regOffset < sizeof(GpioDataRegs)/2; regOffset++)
        {
            gpioBaseAddr[regOffset] = 0x00000000;
        }
    
        EDIS;
    }
    
    
    //
    // GPIO_SetupPinMux - Set the peripheral muxing for the specified pin. The
    //                    appropriate parameters can be found in the GPIO Muxed
    //                    Pins table in the datasheet. Use the GPIO index row
    //                   (0 to 15) to select a muxing option for the GPIO.
    //
    void GPIO_SetupPinMux(Uint16 pin, Uint16 cpu, Uint16 peripheral)
    {
        volatile Uint32 *gpioBaseAddr;
        volatile Uint32 *mux, *gmux, *csel;
        Uint16 pin32, pin16, pin8;
    
        pin32 = pin % 32;
        pin16 = pin % 16;
        pin8 = pin % 8;
        gpioBaseAddr = (Uint32 *)&GpioCtrlRegs + (pin/32)*GPY_CTRL_OFFSET;
    
        //
        //Sanity check for peripheral values
        //
        if (peripheral > 0xF)
        {
            return;
        }
    
        //
        //Create pointers to the appropriate registers. This is a workaround
        //for the way GPIO registers are defined. The standard definition
        //in the header file makes it very easy to do named accesses of one
        //register or bit, but hard to do arbitrary numerical accesses. It's
        //easier to have an array of GPIO modules with identical registers,
        //including arrays for multi-register groups like GPyCSEL1-4. But
        //the header file doesn't define anything we can turn into an array,
        //so manual pointer arithmetic is used instead.
        //
        mux = gpioBaseAddr + GPYMUX + pin32/16;
        gmux = gpioBaseAddr + GPYGMUX + pin32/16;
        csel = gpioBaseAddr + GPYCSEL + pin32/8;
    
        //
        //Now for the actual function
        //
        EALLOW;
    
        //
        //To change the muxing, set the peripheral mux to 0/GPIO first to avoid
        //glitches, then change the group mux, then set the peripheral mux to
        //its target value. Finally, set the CPU select. This procedure is
        //described in the TRM. Unfortunately, since we don't know the pin in
        //advance we can't hardcode a bitfield reference, so there's some tricky
        //bit twiddling here.
        //
        *mux &= ~(0x3UL << (2*pin16));
        *gmux &= ~(0x3UL << (2*pin16));
        *gmux |= (Uint32)((peripheral >> 2) & 0x3UL) << (2*pin16);
        *mux |= (Uint32)(peripheral & 0x3UL) << (2*pin16);
    
        *csel &= ~(0x3L << (4*pin8));
        *csel |= (Uint32)(cpu & 0x3L) << (4*pin8);
    
        //
        //WARNING: This code does not touch the analog mode select registers,
        //which are needed to give the USB module control of its IOs.
        //
    
        EDIS;
    }
    
    //
    // GPIO_SetupPinOptions - Setup up the GPIO input/output options for the
    //                        specified pin.
    //                        The flags are a 16-bit mask produced by ORing
    //                        together options.
    //                        For input pins, the valid flags are:
    //                        GPIO_PULLUP  Enable pull-up
    //                        GPIO_INVERT  Enable input polarity inversion
    //                        GPIO_SYNC    Synchronize the input latch to PLLSYSCLK
    //                                     (default-you don't need to specify this)
    //                        GPIO_QUAL3   Use 3-sample qualification
    //                        GPIO_QUAL6   Use 6-sample qualification
    //                        GPIO_ASYNC   Do not use synchronization or
    //                                     qualification
    //                        (Note: only one of SYNC, QUAL3, QUAL6, or ASYNC is
    //                         allowed)
    //
    //                        For output pins, the valid flags are:
    //                        GPIO_OPENDRAIN   Output in open drain mode
    //                        GPIO_PULLUP      If open drain enabled, also enable
    //                                         the pull-up and the input
    //                                         qualification flags
    //                                        (SYNC/QUAL3/QUAL6/SYNC) listed above.
    //
    //                        With no flags, the default input state is synchronous
    //                        with no pull-up or polarity inversion. The default
    //                        output state is the standard digital output.
    //
    void GPIO_SetupPinOptions(Uint16 pin, Uint16 output, Uint16 flags)
    {
        volatile Uint32 *gpioBaseAddr;
        volatile Uint32 *dir, *pud, *inv, *odr, *qsel;
        Uint32 pin32, pin16, pinMask, qual;
    
        pin32 = pin % 32;
        pin16 = pin % 16;
        pinMask = 1UL << pin32;
        gpioBaseAddr = (Uint32 *)&GpioCtrlRegs + (pin/32)*GPY_CTRL_OFFSET;
    
        //
        //Create pointers to the appropriate registers. This is a workaround
        //for the way GPIO registers are defined. The standard definition
        //in the header file makes it very easy to do named accesses of one
        //register or bit, but hard to do arbitrary numerical accesses. It's
        //easier to have an array of GPIO modules with identical registers,
        //including arrays for multi-register groups like GPyQSEL1-2. But
        //the header file doesn't define anything we can turn into an array,
        //so manual pointer arithmetic is used instead.
        //
        dir = gpioBaseAddr + GPYDIR;
        pud = gpioBaseAddr + GPYPUD;
        inv = gpioBaseAddr + GPYINV;
        odr = gpioBaseAddr + GPYODR;
        qsel = gpioBaseAddr + GPYQSEL + pin32/16;
    
        EALLOW;
    
        //
        //Set the data direction
        //
        *dir &= ~pinMask;
        if (output == 1)
        {
            //
            //Output, with optional open drain mode and pull-up
            //
            *dir |= pinMask;
    
            //
            //Enable open drain if necessary
            //
            if (flags & GPIO_OPENDRAIN)
            {
                *odr |= pinMask;
            }
            else
            {
                *odr &= ~pinMask;
            }
    
            //
            //Enable pull-up if necessary. Open drain mode must be active.
            //
            if (flags & (GPIO_OPENDRAIN | GPIO_PULLUP))
            {
                *pud &= ~pinMask;
            }
            else
            {
                *pud |= pinMask;
            }
        }
        else
        {
            //
            //Input, with optional pull-up, qualification, and polarity inversion
            //
            *dir &= ~pinMask;
    
            //
            //Enable pull-up if necessary
            //
            if (flags & GPIO_PULLUP)
            {
                *pud &= ~pinMask;
            }
            else
            {
                *pud |= pinMask;
            }
    
            //
            //Invert polarity if necessary
            //
            if (flags & GPIO_INVERT)
            {
                *inv |= pinMask;
            }
            else
            {
                *inv &= ~pinMask;
            }
        }
    
        //
        //Extract the qualification parameter and load it into the register.
        //This is also needed for open drain outputs, so we might as well do it
        //all the time.
        //
        qual = (flags & GPIO_ASYNC) / GPIO_QUAL3;
        *qsel &= ~(0x3L << (2 * pin16));
        if (qual != 0x0)
        {
            *qsel |= qual << (2 * pin16);
        }
    
        EDIS;
    }
    
    //
    // GPIO_SetupLock - Enable or disable the GPIO register bit lock for the
    //                  specified pin.
    //                  The valid flags are:
    //                  GPIO_UNLOCK   Unlock the pin setup register bits for the
    //                                specified pin
    //                  GPIO_LOCK     Lock the pin setup register bits for the
    //                                specified pin
    //
    void GPIO_SetupLock(Uint16 pin, Uint16 flags)
    {
        volatile Uint32 *gpioBaseAddr;
        volatile Uint32 *lock;
        Uint32 pin32, pinMask;
    
        pin32 = pin % 32;
        pinMask = 1UL << pin32;
        gpioBaseAddr = (Uint32 *)&GpioCtrlRegs + (pin/32)*GPY_CTRL_OFFSET;
    
        //
        //Create pointers to the appropriate registers. This is a workaround
        //for the way GPIO registers are defined. The standard definition
        //in the header file makes it very easy to do named accesses of one
        //register or bit, but hard to do arbitrary numerical accesses. It's
        //easier to have an array of GPIO modules with identical registers,
        //including arrays for multi-register groups like GPyQSEL1-2. But
        //the header file doesn't define anything we can turn into an array,
        //so manual pointer arithmetic is used instead.
        //
        lock = gpioBaseAddr + GPYLOCK;
    
        EALLOW;
        if(flags)
        {
            //
            //Lock the pin
            //
            *lock |= pinMask;
        }
        else
        {
            //
            //Unlock the pin
            //
            *lock &= ~pinMask;
        }
        EDIS;
    }
    
    //
    // GPIO_SetupXINT1Gpio - External interrupt setup
    //
    void GPIO_SetupXINT1Gpio(Uint16 pin)
    {
        EALLOW;
        InputXbarRegs.INPUT4SELECT = pin;       //Set XINT1 source to GPIO-pin
        EDIS;
    }
    
    //
    // GPIO_SetupXINT2Gpio - External interrupt setup
    //
    void GPIO_SetupXINT2Gpio(Uint16 pin)
    {
        EALLOW;
        InputXbarRegs.INPUT5SELECT = pin;       //Set XINT2 source to GPIO-pin
        EDIS;
    }
    
    //
    // GPIO_SetupXINT3Gpio - External interrupt setup
    //
    void GPIO_SetupXINT3Gpio(Uint16 pin)
    {
        EALLOW;
        InputXbarRegs.INPUT6SELECT = pin;       //Set XINT3 source to GPIO-pin
        EDIS;
    }
    
    //
    // GPIO_SetupXINT4Gpio - External interrupt setup
    //
    void GPIO_SetupXINT4Gpio(Uint16 pin)
    {
        EALLOW;
        InputXbarRegs.INPUT13SELECT = pin;     //Set XINT4 source to GPIO-pin
        EDIS;
    }
    
    //
    // GPIO_SetupXINT5Gpio - External interrupt setup
    //
    void GPIO_SetupXINT5Gpio(Uint16 pin)
    {
        EALLOW;
        InputXbarRegs.INPUT14SELECT = pin;     //Set XINT5 source to GPIO-pin
        EDIS;
    }
    
    //
    // GPIO_EnableUnbondedIOPullupsFor176Pin - Enable pullups for the unbonded
    //                                         GPIOs on the 176PTP package:
    //                                         GPIOs     Grp Bits
    //                                         95-132    C   31
    //                                                   D   31:0
    //                                                   E   4:0
    //                                         134-168   E   31:6
    //                                                   F   8:0
    //
    void GPIO_EnableUnbondedIOPullupsFor176Pin()
    {
        EALLOW;
        GpioCtrlRegs.GPCPUD.all = ~0x80000000;  //GPIO 95
        GpioCtrlRegs.GPDPUD.all = ~0xFFFFFFF7;  //GPIOs 96-127
        GpioCtrlRegs.GPEPUD.all = ~0xFFFFFFDF;  //GPIOs 128-159 except for 133
        GpioCtrlRegs.GPFPUD.all = ~0x000001FF;  //GPIOs 160-168
        EDIS;
    }
    
    //
    // GPIO_EnableUnbondedIOPullupsFor100Pin - Enable pullups for the unbonded
    //                                         GPIOs on the 100PZ package:
    //                                         GPIOs     Grp Bits
    //                                         0-1       A   1:0
    //                                         5-9       A   9:5
    //                                         22-40     A   31:22
    //                                                   B   8:0
    //                                         44-57     B   25:12
    //                                         67-68     C   4:3
    //                                         74-77     C   13:10
    //                                         79-83     C   19:15
    //                                         93-168    C   31:29
    //                                                   D   31:0
    //                                                   E   31:0
    //                                                   F   8:0
    //
    void GPIO_EnableUnbondedIOPullupsFor100Pin()
    {
        EALLOW;
        GpioCtrlRegs.GPAPUD.all = ~0xFFC003E3;  //GPIOs 0-1, 5-9, 22-31
        GpioCtrlRegs.GPBPUD.all = ~0x03FFF1FF;  //GPIOs 32-40, 44-57
        GpioCtrlRegs.GPCPUD.all = ~0xE10FBC18;  //GPIOs 67-68, 74-77, 79-83, 93-95
        GpioCtrlRegs.GPDPUD.all = ~0xFFFFFFF7;  //GPIOs 96-127
        GpioCtrlRegs.GPEPUD.all = ~0xFFFFFFFF;  //GPIOs 128-159
        GpioCtrlRegs.GPFPUD.all = ~0x000001FF;  //GPIOs 160-168
        EDIS;
    }
    
    //
    // GPIO_EnableUnbondedIOPullups - Enable IO pullups for specific package
    //
    void GPIO_EnableUnbondedIOPullups()
    {
        unsigned char pin_count = ((DevCfgRegs.PARTIDL.all & 0x00000700) >> 8) ;
    
        //
        // 5 = 100 pin
        // 6 = 176 pin
        // 7 = 337 pin
        //
        if(pin_count == 5)
        {
            GPIO_EnableUnbondedIOPullupsFor100Pin();
        }
        else if (pin_count == 6)
        {
            GPIO_EnableUnbondedIOPullupsFor176Pin();
        }
        else
        {
            //
            //do nothing - this is 337 pin package
            //
        }
    }
    
    //
    // GPIO_ReadPin - Read the GPyDAT register bit for the specified pin.
    //                Note that this returns the actual state of the pin,
    //                not the state of the output latch.
    //
    Uint16 GPIO_ReadPin(Uint16 pin)
    {
        volatile Uint32 *gpioDataReg;
        Uint16 pinVal;
    
        gpioDataReg = (volatile Uint32 *)&GpioDataRegs + (pin/32)*GPY_DATA_OFFSET;
        pinVal = (gpioDataReg[GPYDAT] >> (pin % 32)) & 0x1;
    
        return pinVal;
    }
    
    //
    // GPIO_WritePin - Set the GPyDAT register bit for the specified pin.
    //
    void GPIO_WritePin(Uint16 pin, Uint16 outVal)
    {
        volatile Uint32 *gpioDataReg;
        Uint32 pinMask;
    
        gpioDataReg = (volatile Uint32 *)&GpioDataRegs + (pin/32)*GPY_DATA_OFFSET;
        pinMask = 1UL << (pin % 32);
    
        if (outVal == 0)
        {
            gpioDataReg[GPYCLEAR] = pinMask;
        }
        else
        {
            gpioDataReg[GPYSET] = pinMask;
        }
    }
    
    //
    // End of file
    //
    

    //###########################################################################
    //
    // FILE:   Example_2837xSSci_FFDLB_int.c
    //
    // TITLE:  SCI Digital Loop Back with Interrupts.
    //
    //! \addtogroup cpu01_example_list
    //! <h1>SCI Digital Loop Back with Interrupts (sci_loopback_interrupts)</h1>
    //!
    //!  This program uses the internal loop back test mode of the peripheral.
    //!  Other then boot mode pin configuration, no other hardware configuration
    //!  is required. Both interrupts and the SCI FIFOs are used.
    //!
    //!  A stream of data is sent and then compared to the received stream.
    //!  The SCI-A sent data looks like this: \n
    //!  00 01 \n
    //!  01 02 \n
    //!  02 03 \n
    //!  .... \n
    //!  FE FF \n
    //!  FF 00 \n
    //!  etc.. \n
    //!  The pattern is repeated forever.
    //!
    //!  \b Watch \b Variables \n
    //!  - \b sdataA - Data being sent
    //!  - \b rdataA - Data received
    //!  - \b rdata_pointA - Keep track of where we are in the data stream.
    //!    This is used to check the incoming data
    //!
    //
    //###########################################################################
    // $TI Release: F2837xS Support Library v3.09.00.00 $
    // $Release Date: Thu Mar 19 07:39:41 IST 2020 $
    // $Copyright:
    // Copyright (C) 2014-2020 Texas Instruments Incorporated - http://www.ti.com/
    //
    // Redistribution and use in source and binary forms, with or without 
    // modification, are permitted provided that the following conditions 
    // are met:
    // 
    //   Redistributions of source code must retain the above copyright 
    //   notice, this list of conditions and the following disclaimer.
    // 
    //   Redistributions in binary form must reproduce the above copyright
    //   notice, this list of conditions and the following disclaimer in the 
    //   documentation and/or other materials provided with the   
    //   distribution.
    // 
    //   Neither the name of Texas Instruments Incorporated nor the names of
    //   its contributors may be used to endorse or promote products derived
    //   from this software without specific prior written permission.
    // 
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // $
    //###########################################################################
    
    //
    // Included Files
    //
    #include "F28x_Project.h"
    
    //
    // Defines
    //
    #define CPU_FREQ        60E6
    #define LSPCLK_FREQ     CPU_FREQ/4
    #define SCI_FREQ        100E3
    #define SCI_PRD         ((LSPCLK_FREQ/(SCI_FREQ*8))-1)
    
    //
    // Globals
    //
    Uint16 sdataA[2];    // Send data for SCI-A
    Uint16 rdataA[2];    // Received data for SCI-A
    Uint16 rdata_pointA; // Used for checking the received data
    
    //
    // Function Prototypes
    //
    interrupt void sciaTxFifoIsr(void);
    interrupt void sciaRxFifoIsr(void);
    void scia_fifo_init(void);
    void error(void);
    
    //
    // Main
    //
    void main(void)
    {
       Uint16 i;
    
    //
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the F2837xS_SysCtrl.c file.
    //
       InitSysCtrl();
    
    //
    // Step 2. Initialize GPIO:
    // This example function is found in the F2837xS_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    //
       InitGpio();
    
    //
    // For this example, only init the pins for the SCI-A port.
    //  GPIO_SetupPinMux() - Sets the GPxMUX1/2 and GPyMUX1/2 register bits
    //  GPIO_SetupPinOptions() - Sets the direction and configuration of the GPIOS
    // These functions are found in the F2837xS_Gpio.c file.
    //
       GPIO_SetupPinMux(28, GPIO_MUX_CPU1, 1);
       GPIO_SetupPinOptions(28, GPIO_INPUT, GPIO_PUSHPULL);
       GPIO_SetupPinMux(29, GPIO_MUX_CPU1, 1);
       GPIO_SetupPinOptions(29, GPIO_OUTPUT, GPIO_ASYNC);
    
    //
    // Step 3. Clear all interrupts and initialize PIE vector table:
    // Disable CPU interrupts
    //
       DINT;
    
    //
    // Initialize PIE control registers to their default state.
    // The default state is all PIE interrupts disabled and flags
    // are cleared.
    // This function is found in the F2837xS_PieCtrl.c file.
    //
       InitPieCtrl();
    
    //
    // Disable CPU interrupts and clear all CPU interrupt flags:
    //
       IER = 0x0000;
       IFR = 0x0000;
    
    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the interrupt
    // is not used in this example.  This is useful for debug purposes.
    // The shell ISR routines are found in F2837xS_DefaultIsr.c.
    // This function is found in F2837xS_PieVect.c.
    //
       InitPieVectTable();
    
    //
    // Interrupts that are used in this example are re-mapped to
    // ISR functions found within this file.
    //
       EALLOW;  // This is needed to write to EALLOW protected registers
       PieVectTable.SCIA_RX_INT = &sciaRxFifoIsr;
       PieVectTable.SCIA_TX_INT = &sciaTxFifoIsr;
       EDIS;    // This is needed to disable write to EALLOW protected registers
    
    //
    // Step 4. Initialize the Device Peripherals:
    //
       scia_fifo_init();  // Init SCI-A
    
    //
    // Step 5. User specific code, enable interrupts:
    //
    // Init send data.  After each transmission this data
    // will be updated for the next transmission
    //
       for(i = 0; i<2; i++)
       {
          sdataA[i] = i;
       }
    
       rdata_pointA = sdataA[0];
    
    //
    // Enable interrupts required for this example
    //
       PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
       PieCtrlRegs.PIEIER9.bit.INTx1 = 1;   // PIE Group 9, INT1
       PieCtrlRegs.PIEIER9.bit.INTx2 = 1;   // PIE Group 9, INT2
       IER = 0x100;                         // Enable CPU INT
       EINT;
    
    //
    // Step 6. IDLE loop. Just sit and loop forever (optional):
    //
        for(;;);
    }
    
    //
    // error - Function to halt debugger on error
    //
    void error(void)
    {
        asm("     ESTOP0"); // Test failed!! Stop!
        for (;;);
    }
    
    //
    // sciaTxFifoIsr - SCIA Transmit FIFO ISR
    //
    interrupt void sciaTxFifoIsr(void)
    {
        Uint16 i;
    
        for(i=0; i< 2; i++)
        {
           SciaRegs.SCITXBUF.all=sdataA[i];  // Send data
        }
    
        for(i=0; i< 2; i++)                  // Increment send data for next cycle
        {
           sdataA[i] = (sdataA[i]+1) & 0x00FF;
        }
    
        SciaRegs.SCIFFTX.bit.TXFFINTCLR=1;   // Clear SCI Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x100;       // Issue PIE ACK
    }
    
    //
    // sciaRxFifoIsr - SCIA Receive FIFO ISR
    //
    interrupt void sciaRxFifoIsr(void)
    {
        Uint16 i;
    
        for(i=0;i<2;i++)
        {
           rdataA[i]=SciaRegs.SCIRXBUF.all;  // Read data
        }
    
        for(i=0;i<2;i++)                     // Check received data
        {
           if(rdataA[i] != ( (rdata_pointA+i) & 0x00FF) )
           {
               error();
           }
        }
    
        rdata_pointA = (rdata_pointA+1) & 0x00FF;
    
        SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1;   // Clear Overflow flag
        SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;   // Clear Interrupt flag
    
        PieCtrlRegs.PIEACK.all|=0x100;       // Issue PIE ack
    }
    
    //
    // scia_fifo_init - Configure SCIA FIFO
    //
    void scia_fifo_init()
    {
       SciaRegs.SCICCR.all = 0x0007;      // 1 stop bit,  No loopback
                                          // No parity,8 char bits,
                                          // async mode, idle-line protocol
       SciaRegs.SCICTL1.all = 0x0003;     // enable TX, RX, internal SCICLK,
                                          // Disable RX ERR, SLEEP, TXWAKE
       SciaRegs.SCICTL2.bit.TXINTENA = 1;
       SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
       SciaRegs.SCIHBAUD.all = ((uint16_t)SCI_PRD  & 0xFF00U) >> 8U;
       SciaRegs.SCILBAUD.all = (uint16_t)SCI_PRD  & 0x00FFU;
       SciaRegs.SCICCR.bit.LOOPBKENA = 1; // Enable loop back
       SciaRegs.SCIFFTX.all = 0xC022;
       SciaRegs.SCIFFRX.all = 0x0022;
       SciaRegs.SCIFFCT.all = 0x00;
    
       SciaRegs.SCICTL1.all = 0x0023;     // Relinquish SCI from Reset
       SciaRegs.SCIFFTX.bit.TXFIFORESET = 1;
       SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
    }
    
    //
    // End of file
    //
    

    Best Regards, Taki

  • Hi Taki,

    After looking through the code, I think there is a few suggestions that could help:

    • Run "initGpio()" and the GPIO configuration BEFORE the PIE vector table gets initialized and before DINT (should not matter, but try it just in case)
    • Perform an SCI software reset before AND after the SCI configuration.
    • After configuring the SCI:
      • Reset the SCIFFTX.SCIRST channel (helpful for TX line)
      • Clear TXRDY and RXRDY_BRKDT with SCICTL.SWRESET
      • Enable RX, TX, and SCI with SCICTL register 
      • Enable SCI_INT_TXRDY and SCI_INT_RXRDY_BRKDT again
    • Now the PIE* registers can be updated
    • Acknowledge the PIE Group to clear it, after finishing the PIE configuraiton and calling EnableInterrupts()

    This should look like the following in your original test.c file:

    void init(void)
    {
    
    	InitSysCtrl();
    
    	//***MOVED***
    	initGpio();
    
    	GPIO_SetupPinMux(	56	,	GPIO_MUX_CPU1	,	6	);	//CFƒJ[ƒh§ŒäiTxDj
    	GPIO_SetupPinMux(	57	,	GPIO_MUX_CPU1	,	6	);	//CFƒJ[ƒh§ŒäiRxDjš
    	GPIO_SetupPinOptions(	56	,	GPIO_OUTPUT	,	GPIO_ASYNC	);	//CFƒJ[ƒh§ŒäiTxDj
    	GPIO_SetupPinOptions(	57	,	GPIO_INPUT	,	GPIO_PUSHPULL	);	//CFƒJ[ƒh§ŒäiRxDjš
    	//***END MOVED***
    
    	DINT;
    	InitPieCtrl();
    	IER = 0x0000;
    	IFR = 0x0000;
    	InitPieVectTable();
    
    	//***ADDED***
    	SCI_performSoftwareReset(SCIA_BASE);
    	//***END ADDED***
    
    	EALLOW;  // This is needed to write to EALLOW protected registers
    	PieVectTable.SCIC_TX_INT			=	&scic_tx_isr;
    	PieVectTable.SCIC_RX_INT			=	&scic_rx_isr;
    	EDIS;    // This is needed to disable write to EALLOW protected registers
    
    	ScicRegs.SCICCR.all					=	0x0007;		//8bit,Idle-line mode,no loop back,no parity,one stop bit
    	ScicRegs.SCICTL1.all				=	0x0003;		//TX,RX enable, internal SCK clk,ERR,SLEEP,TXWAKE disable
    	ScicRegs.SCICTL2.bit.TXINTENA		=	1;			//TX int disable
    	ScicRegs.SCICTL2.bit.RXBKINTENA		=	1;			//RX int enable
    	ScicRegs.SCIHBAUD.all				=	((uint16_t)CF_SCI_PRD  & 0xFF00U) >> 8U;
    	ScicRegs.SCILBAUD.all				=	(uint16_t)CF_SCI_PRD  & 0x00FFU;
    	ScicRegs.SCIFFTX.all				=	0xC022;		//TXŠ„‚荞‚Ý‚ÍFIFO‚ª15ˆÈ‰º‚Å”­¶
    	ScicRegs.SCIFFRX.all				=	0x0022;		//RXŠ„‚荞‚Ý‚ÍFIFO‚ª1ˆÈã‚Å”­¶
    	ScicRegs.SCIFFCT.all = 0x00;
    
    	ScicRegs.SCICTL1.all				=	0x0023;		//SCIƒ\ƒtƒgƒEƒFƒAƒŠƒZƒbƒg
    	ScicRegs.SCIFFTX.bit.TXFIFORESET	=	1;			//TX FIFOƒŠƒZƒbƒg
    	ScicRegs.SCIFFRX.bit.RXFIFORESET	=	1;			//RX FIFOƒŠƒZƒbƒg
    	
    	//***ADDED***
        SCI_resetChannels(SCIB_BASE); //RESET SCIFFTX.SCIRST
        SCI_performSoftwareReset(SCIB_BASE); //CLEAR TXRDY AND RXRDY_BRKDT (BY SCICTL*.SWRESET)
        SCI_enableModule(SCIB_BASE); //ENABLE RX, TX, AND SCI IN CTL REGISTER
        SCI_performSoftwareReset(SCIB_BASE); //RESET SCI WITH SCICTL*.SWRESET
        SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT); //ENABLE SCI_INT_TXRDY AND SCI_INT_RXRDY_BRKDT
        //***END ADDED***
    	
    
        //NOW CAN ENABLE INTERRUPTS IN PIE BLOCK
    	PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
    	PieCtrlRegs.PIEIER8.bit.INTx5					=	1;
    	PieCtrlRegs.PIEIER8.bit.INTx6					=	1;
    	IER									|=	M_INT8;
    
    	EnableInterrupts();
    
    	//***ADDED***
    	Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP8); //ACKNOWLEDGE GROUP
    	//**END ADDED***
    
    	EINT;
    	ERTM;  // Enable Global realtime interrupt DBGM
    }
    

    I would highly suggest using the newest version of C2000Ware (3.02.00.00), as the one provided in this thread is a few versions old already (2.01.00.00), and may have some fixes that have been implemented since then!

    Let me know if the above suggestions assist with your problem!

    Regards,

    Vince

  • Hi, Vince

    The customer has solved the issue as a result of debugging following your advice.
    They thank you for all the help you have given them.

    They let me know that the root cause was that RTS and CTS was implemented in their original code.
    I think that their code may kept to wait CTS signal before reading the received data.

    Anyway, thank a lot for your help.
    Best Regards, Taki