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.

TMS320F280039C: Error in C2000 academy program for SCI lab for TMS320F280039C

Part Number: TMS320F280039C

Hi Team,

In below code shouldn't the code for starting the timer be  CPUTimer_startTimer(myCPUTIMER0_BASE);

Also when I run the code in the terminal window it is printing the message 

which is half of

    

Please let me know why this is happening.

Thanks.

  • Hi,

    Thank you for trying C2000 Academy and providing the feedback. Can you please elaborate what is the issue? Is timer not starting?

    Regards, Santosh

  • Hi Santosh,

    Basically the CPUTimer_startTimer(INT_myCPUTIMER0) does not start the timer as mentioned in the academy lab. The base address should be the parameter but here the Interrupt is the parameter.

    The correct syntax should be CPUTimer_startTimer(uint32_t base).

    For the second issue the message printed on the terminal is somehow getting skipped.

  • Hi Prayag,

    Thank you so much for pointing to the bug which was introduced in last release. It came right on time. We are getting ready for the next release, and it will be fixed in the release.

    First part: 

    //
    // Start CPU Timer 0
    //
    CPUTimer_startTimer(myCPUTIMER0_BASE);

    Second issue:

    for(;;)
    {
    msg = "\r\nEnter a number 0-9: \0";
    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg, 24);

    //
    // Read a character from the FIFO.
    //
    receivedChar = SCI_readCharBlockingFIFO(mySCIA_BASE);
    SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar);


    //Turns character to digit
    delayCount = receivedChar - '0';

    rxStatus = SCI_getRxStatus(mySCIA_BASE);
    if((rxStatus & SCI_RXSTATUS_ERROR) != 0)
    {
    //
    //If Execution stops here there is some error
    //Analyze SCI_getRxStatus() API return value
    //
    ESTOP0;
    }

    //
    // Echo back the character.
    //
    msg = " LED set to blink rate \0";
    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg, 25);
    }

    Please try this and confirm if it resolves your both issues.

    Regards, Santosh

  • Hi Santosh,

    It did not work. Apparently the issue is with SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar);

    Check this piece of code that I used. Instead of SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar); I used SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg2, 1); and it worked properly.

    The result is

     

  • Hi Santosh,

    This is the result with your suggested code.

    Correcting my earlier statement. Your suggested code worked.

    But 

    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg, 25);

    SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar);

    together shows wrong result(snap attached at start of thread).

  • Prayag,

    Thanks for confirming that the suggested code worked for you. 

    Regards, Santosh

  • Thank You for your support Santosh.

    But I am still not clear on why the below 2 lines executed together does not work.

    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg, 25);

    SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar);

  • Prayag,

    First of all, control flow wise, it should do 

    SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar); 

    right after receive. It is just to echo the character for user.

    The issue is coming how  SCI_writeCharArray() and SCI_writeCharBlockingFIFO() function is implemented.

    SCI_writeCharArray() function waits for 2 character in FIFO to put the TXBUF, but SCI_writeCharBlockingFIFO() just waits for 1 char in FIFO. That causes the flow issue.

    If you want to keep the original flow, then change 

    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg, 25);

    SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar);

    to 

    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg, 25);
    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)receivedChar, 1);

    That should also work. 

    Hope this helps.

    Regards, Santosh

  • SCI_writeCharArray() function waits for 2 character in FIFO to put the TXBUF, but SCI_writeCharBlockingFIFO() just waits for 1 char in FIFO. That causes the flow issue.

    Can you please elaborate on this.

     

    If you want to keep the original flow, then change 

    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg, 25);

    SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar);

    Here when I put some delay after both the line the flow was intact.

  • Prayag,

    Can you please elaborate on this.

    It will be easier to understand, if you step in the function 

    SCI_writeCharArray() function and SCI_writeCharBlockingFIFO()

    Regards, Santosh

  • Hi Santosh,

    SCI_writeCharArray(mySCIA_BASE, (uint16_t*)msg, 25);

    SCI_writeCharBlockingFIFO(mySCIA_BASE, receivedChar);

    DEVICE_DELAY_US(1000000);

    with this code the flow was intact.

  • If it works for you, please use the delay.

    If you want to understand further, please step into the implementation of the function.

    Regards, Santosh