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.

SCI Communication not working in standalone mode

Other Parts Discussed in Thread: TMS320F28027F, CONTROLSUITE

Hi All

I am using the C2000 LaunchpadXL (TMS320F28027F). I ran the SCI Echoback example from the debugger in CCS with no problems and managed to send messages back and forth from a terminal. however, when I try to reboot the device in standalone mode, the messages coming through are garbage, almost as if the baud rate is wrong. Can anyone help with this? To boot in standalone mode I am just switching S3 off and leaving S1 and S2 on. S4 is on so I can communicate via usb.

Thanks in advance

Matt

  • Hi Matt,

    Are you running the code through Flash or RAM?

    Regards,
    Gautam
  • Hi Gautam

    Gautam Iyer said:


    Are you running the code through Flash or RAM? 

    I am running through Flash. I notice that if I debug through CCS, and then hit the reset button, the SCI communication continues to work, but as soon as I recycle power it stops working, so I am guessing it is something to do with how I am booting.

  • When you recycle power, I wanted to know whether rest of your program performs as expected? Also, check whether you boot mode is set to GET mode.
  • I am blinking an LED which works as expected, but the SCI does not work as expected. You'll have to forgive me, I only half know what I am doing. How do I set the boot mode to GET mode?
  • Matt Weyer said:
    I am blinking an LED which works as expected, but the SCI does not work as expected.

    That's unusual! Please confirm the boot mode...

    Matt Weyer said:
    How do I set the boot mode to GET mode?

    By setting the Switch positions on the launchpad:

    Check the launchpad schematics to get more details.

    Regards,

    Gautam

  • Sorry for the delayed reply. I did boot in Get Mode. I don't know if it is worth mentioning but I did hack the Echoback example a bit so that it worked on the SCI interrupt. Here is my code

    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    #include "f2802x_common/include/adc.h"
    #include "f2802x_common/include/clk.h"
    #include "f2802x_common/include/flash.h"
    #include "f2802x_common/include/gpio.h"
    #include "f2802x_common/include/pie.h"
    #include "f2802x_common/include/pll.h"
    #include "f2802x_common/include/sci.h"
    #include "f2802x_common/include/wdog.h"
    
    // Prototype statements for functions found within this file.
    interrupt void sciaRxFifoIsr(void);
    void scia_echoback_init(void);
    void scia_fifo_init(void);
    void scia_xmit(uint16_t a);
    void scia_msg(char *msg);
    
    // Global counts used in this example
    uint16_t LoopCount;
    uint16_t ErrorCount;
    uint16_t ReceivedChar;
    char *msg;
    
    
    ADC_Handle myAdc;
    CLK_Handle myClk;
    FLASH_Handle myFlash;
    GPIO_Handle myGpio;
    PIE_Handle myPie;
    SCI_Handle mySci;
    
    void main(void)
    {
        CPU_Handle myCpu;
        PLL_Handle myPll;
        WDOG_Handle myWDog;
    
        // Initialize all the handles needed for this application
        myAdc = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
        myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
        myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
        myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
        myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
        myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
        myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
        mySci = SCI_init((void *)SCIA_BASE_ADDR, sizeof(SCI_Obj));
        myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));
    
        // Perform basic system initialization
        WDOG_disable(myWDog);
        CLK_enableAdcClock(myClk);
        (*Device_cal)();
    
        //Select the internal oscillator 1 as the clock source
        CLK_setOscSrc(myClk, CLK_OscSrc_Internal);
    
        // Setup the PLL for x12 /2 which will yield 60Mhz = 10Mhz * 12 / 2
        PLL_setup(myPll, PLL_Multiplier_12, PLL_DivideSelect_ClkIn_by_2);
    
        // If running from flash copy RAM only functions to RAM
    #ifdef _FLASH
        memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
    #endif
    
    
        // Initalize GPIO
        GPIO_setPullUp(myGpio, GPIO_Number_28, GPIO_PullUp_Enable);
        GPIO_setPullUp(myGpio, GPIO_Number_29, GPIO_PullUp_Disable);
        GPIO_setQualification(myGpio, GPIO_Number_28, GPIO_Qual_ASync);
        GPIO_setMode(myGpio, GPIO_Number_28, GPIO_28_Mode_SCIRXDA);
        GPIO_setMode(myGpio, GPIO_Number_29, GPIO_29_Mode_SCITXDA);
    
        // Setup a debug vector table and enable the PIE
        PIE_enable(myPie);
    
        // 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
    	((PIE_Obj *)myPie)->SCIRXINTA = &sciaRxFifoIsr;
    	EDIS;   // This is needed to disable write to EALLOW protected registers
    
    	// Register interrupt handlers in the PIE vector table
    	PIE_registerPieIntHandler(myPie, PIE_GroupNumber_9, PIE_SubGroupNumber_1, (intVec_t)&sciaRxFifoIsr);
    
        // Enable interrupts required for this example
        PIE_enableInt(myPie, PIE_GroupNumber_9, PIE_InterruptSource_SCIARX);
    
        CPU_enableInt(myCpu, CPU_IntNumber_9);
        CPU_enableGlobalInts(myCpu);
    
        LoopCount = 0;
        ErrorCount = 0;
    
        scia_echoback_init();  // Initalize SCI for echoback
        //scia_fifo_init();      // Initialize the SCI FIFO
    
        msg = "\r\n\n\nHello World!\0";
        scia_msg(msg);
    
        msg = "\r\nYou will enter a character, and the DSP will echo it back! \n\0";
        scia_msg(msg);
    
        for(;;)
        {}
    
    }
    
    interrupt void sciaRxFifoIsr(void)
    {
    	msg = "\r\nEnter a character: \0";
    	scia_msg(msg);
    
    	// Get character
    	ReceivedChar = SCI_getData(mySci);
    
    	// Echo character back
    	msg = "  You sent: \0";
    	scia_msg(msg);
    	scia_xmit(ReceivedChar);
    
    	LoopCount++;
    
        // Clear Overflow flag
        SCI_clearRxFifoOvf(mySci);
    
        // Clear Interrupt flag
        SCI_clearRxFifoInt(mySci);
    
        // Issue PIE ack
        PIE_clearInt(myPie, PIE_GroupNumber_9);
    }
    
    // Test 1,SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
    void scia_echoback_init()
    {
    
        CLK_enableSciaClock(myClk);
    
        // 1 stop bit,  No loopback
        // No parity,8 char bits,
        // async mode, idle-line protocol
        SCI_disableParity(mySci);
        SCI_setNumStopBits(mySci, SCI_NumStopBits_One);
        SCI_setCharLength(mySci, SCI_CharLength_8_Bits);
    
        SCI_enableTx(mySci);
        SCI_enableRx(mySci);
        SCI_enableRxInt(mySci);
    
        // SCI BRR = LSPCLK/(SCI BAUDx8) - 1
    #if (CPU_FRQ_60MHZ)
        SCI_setBaudRate(mySci, SCI_BaudRate_115_2_kBaud);
    #elif (CPU_FRQ_50MHZ)
        SCI_setBaudRate(mySci, SCI_BaudRate_9_6_kBaud);
    #elif (CPU_FRQ_40MHZ)
        SCI_setBaudRate(mySci, (SCI_BaudRate_e)129);
    #endif
    
        SCI_enable(mySci);
    
        return;
    }
    
    // Transmit a character from the SCI
    void scia_xmit(uint16_t a)
    {
    //    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
        while(SCI_getTxFifoStatus(mySci) != SCI_FifoStatus_Empty){
        }
    //    SciaRegs.SCITXBUF=a;
        SCI_putDataBlocking(mySci, a);
    
    }
    
    void scia_msg(char * msg)
    {
        int i;
        i = 0;
        while(msg[i] != '\0')
        {
            scia_xmit(msg[i]);
            i++;
        }
    }
    
    // Initalize the SCI FIFO
    void scia_fifo_init()
    {
    
        SCI_enableFifoEnh(mySci);
        SCI_resetTxFifo(mySci);
        SCI_clearTxFifoInt(mySci);
        SCI_resetChannels(mySci);
        SCI_setTxFifoIntLevel(mySci, SCI_FifoLevel_Empty);
    
        SCI_resetRxFifo(mySci);
        SCI_clearRxFifoInt(mySci);
        SCI_setRxFifoIntLevel(mySci, SCI_FifoLevel_Empty);
        SCI_enableRxFifoInt(mySci);
    
        return;
    }
    
    //===========================================================================
    // No more.
    //===========================================================================
    
    

  • *UPDATE*

    I have found out that if I reboot in Get Mode it does not work initially but then works after I hit the reset switch...

  • Matt, I would like you to try the structured sci examples instead of driver based.
    c:/ti/controlSuite/device_support/F2802x/v20x/struct (not the exact path but you can figure it out)

    Regards,
    Gautam
  • Hi Matt,

    "I have found out that if I reboot in Get Mode it does not work initially but then works after I hit the reset switch..."

    What's is the definition of your term 'reboot'?   Turn on the power after it has been off?


    Thank you,
    Brett

  • Brett

    Yes by reboot I meant recycle power. I have since solved my problem though. Too many stupid errors to even mention the solution. However, I must thank you both for the help. Much appreciated.

    Matt