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.

CCS/TMS320F28069M: F28069: SCIA UART reception issue (interrupt based)

Part Number: TMS320F28069M
Other Parts Discussed in Thread: MOTORWARE, C2000WARE, CONTROLSUITE

Tool/software: Code Composer Studio

Ref: https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/334989#pi320995=1

I have implemented a similar structure by  and other, nice discussions, I have UART-TX working on 115K2 (after changing the CLK/PLL since I use 20MHz XOSC for 90MHz SYSCLK) but not sure what going in UART-RX since it not working too well.

I have added several things in hal.c/h, copied over the sci.h/c to project folder to fix BAUD rate for F28069M via enum listing. UART-TX is working good.

Do you have working code or perhaps take a look into attached for the proposed solution?, interrupt did response but it not collecting RX data for some reason. 

This is the code below: 

//====================================================
//====================================================SCI Receive Data ISR
// Purpose  :
// Input    :
// Output   :
// Note     :
// Status   :
//====================================================
interrupt void SCI_RX_ISR(void)
{
    SCI_Obj *sci = (SCI_Obj *)halHandle->sciAHandle;
    bool status;
    status = (bool) ((sci->SCIRXST & SCI_SCIRXST_RXRDY_BITS) >> 6);
    //if(SCI_rxDataReady(halHandle->sciAHandle)==1)
    if (status == true)
    {
        rxCommand[rxCommandPtr] = SCI_read(halHandle->sciAHandle);
        rxCommandPtr++;
        if (rxCommand[rxCommandPtr]=='\n')
        {
            ifEOFDetected=true;
        }
      //SCI_write_char(halHandle->sciAHandle, rev_data);
    }
    SCI_clearRxFifoOvf(halHandle->sciAHandle);
    SCI_clearRxFifoInt(halHandle->sciAHandle);
    PIE_clearInt(halHandle->pieHandle,PIE_GroupNumber_9);      // Acknowledge interrupt from PIE group 9
}

/*****************************************************************************
 *   Copyright (C) 2020 : AOT, Leduc.
 *
 *   All Right Reserved.
 *****************************************************************************
 *
 *   FILENAME   : ZptintF.c/h
 *   PURPOSE    : Send ASCII based message into USB (CDC) or UART stream
 *   AUTHOR     : Richard Payne
 *   REVISION   :
 *   History    : 3A: Upgrade code to match ESM project including session Log L2(....). \
 *              : 3A: Updated Welcome Message. Along with advanced Augment support as from ESM.
 *   NOTE       :
 *   Setup      : Make use of USB (CDC) or UART0 port
 *              :
 *              :
 ******************************************************************************/
#include "Universal_Macro.h"
//-------------------------------------MotorWare/C2000Ware Lib.
#include "hal.h"
#include "user.h"
#include "hal_obj.h"
//#include "sw/drivers/sci/src/32b/f28x/f2806x/sci.h"
//-------------------------------------Local Project Lib.
#include "RVP_Main.h"
#include "UART_zPrintf.h"
#include "Detokeniser.h"
#include "UART_Command.h"
#include "UART_SCI.h"
#include "SCI.h"

//====================================================
//====================================================HAL_setupSCI
// Purpose  :
// Input    :
// Output   :
// Note     :
// Status   :
//====================================================
void HAL_setupSCI(HAL_Handle handle)
{
      HAL_Obj *obj = (HAL_Obj *) handle;
      // Initialize all SCI registers based on your requirement. This is only example.

      // SCI stop bit, parity, loopback, char bits, idle/address mode
      SCI_setNumStopBits(obj->sciAHandle, SCI_NumStopBits_One);
      //SCI_setParity(obj->sciAHandle, SCI_Parity_Odd);
      SCI_disableParity(obj->sciAHandle);
      SCI_disableLoopBack(obj->sciAHandle);
      SCI_setMode(obj->sciAHandle, SCI_Mode_IdleLine);
      SCI_setCharLength(obj->sciAHandle, SCI_CharLength_8_Bits);

      // TX enable, RX enable, RX ERR INT enable, SLEEP, TXWAKE (SCICTL1 = 0x03)
      SCI_disableRxErrorInt(obj->sciAHandle);
      SCI_disable(obj->sciAHandle);
      SCI_disableTxWake(obj->sciAHandle);
      SCI_disableSleep(obj->sciAHandle);
      SCI_enableTx(obj->sciAHandle);
      SCI_enableRx(obj->sciAHandle);
      SCI_enableTxFifo(obj->sciAHandle);
      SCI_enableTxFifoEnh(obj->sciAHandle);

      // TXINT enable, RXINT enable, TXEMPTY, TXRDY (SCICTL2 = 0x03)
      //SCI_enableRxInt(obj->sciAHandle);
      SCI_enableRxFifoInt(obj->sciAHandle);
      SCI_setRxFifoIntLevel(obj->sciAHandle, SCI_FifoLevel_1_Word);
      SCI_disableTxInt(obj->sciAHandle);

      // SCIH-SCIL BAUD - SCI_BAUD = (LSPCLK/(SCI_BRR*8)) - 1
      SCI_setBaudRate(obj->sciAHandle, SCI_BaudRateRVP_115_2_kBaud);           //SCI_BaudRate_19_2_kBaud

      // Reset SCI
      SCI_enable(obj->sciAHandle);

      // enable SCI interrupt
      PIE_enableInt(obj->pieHandle, PIE_GroupNumber_9, PIE_InterruptSource_SCIARX);

      // enable CPU interrupt
      CPU_enableInt(obj->cpuHandle, CPU_IntNumber_9);
}


//====================================================
//====================================================HAL_setupSCI
// Purpose  :
// Input    :
// Output   :
// Note     :
// Status   :
//====================================================
void SCI_write_char(SCI_Handle sciHandle,char a)
{
    SCI_Obj *sci = (SCI_Obj *)sciHandle;

    while(SCI_getTxFifoStatus(sci) == SCI_FifoStatus_4_Words) { }
    SCI_write(sci, a);
}

//====================================================
//====================================================HAL_setupSCI
// Purpose  :
// Input    :
// Output   :
// Note     :
// Status   :
//====================================================
void SCI_write_str(SCI_Handle sciHandle, char* str)
{
    while(*str != 0)
    {
        SCI_write_char(sciHandle, *str++);
    }
}

//====================================================
//====================================================SCI Receive Data ISR
// Purpose  :
// Input    :
// Output   :
// Note     :
// Status   :
//====================================================
interrupt void SCI_RX_ISR(void)
{
    SCI_Obj *sci = (SCI_Obj *)halHandle->sciAHandle;
    bool status;
    status = (bool) ((sci->SCIRXST & SCI_SCIRXST_RXRDY_BITS) >> 6);
    //if(SCI_rxDataReady(halHandle->sciAHandle)==1)
    if (status == true)
    {
        rxCommand[rxCommandPtr] = SCI_read(halHandle->sciAHandle);
        rxCommandPtr++;
        if (rxCommand[rxCommandPtr]=='\n')
        {
            ifEOFDetected=true;
        }
      //SCI_write_char(halHandle->sciAHandle, rev_data);
    }
    SCI_clearRxFifoOvf(halHandle->sciAHandle);
    SCI_clearRxFifoInt(halHandle->sciAHandle);
    PIE_clearInt(halHandle->pieHandle,PIE_GroupNumber_9);      // Acknowledge interrupt from PIE group 9
}

//====================================================
//====================================================SCI Receive Data ISR
// Purpose  :
// Input    :
// Output   :
// Note     :
// Status   :
//====================================================
void PIE_enableSciInt(PIE_Handle pieHandle,const SCI_IntNumber_e sciType)
{
  PIE_Obj *pie = (PIE_Obj *)pieHandle;
  uint16_t index = 8;         // index is counted from 0, so INT9 has index 8
  uint16_t setValue = (1 << sciType);


  // set the value
  pie->PIEIER_PIEIFR[index].IER |= setValue;

  return;
} // end of PIE_enableSciInt() function
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Command



I attached the code 

  • I found the section on SCI in motorware_hal_tutorial.pdf, not quite easy to find !!!, however, it does not provide a solution for FIFO based. In any case, I have both INT and polling methods working now without FIFO. The C2000Ware and Controlsuite are not compatible with motorware structure and style and there no example code. Motorware lacks demo code for SCI part. The effort took me a whole weekend to familiar MotorWare library structure.

    I note there no F28069 example code in C2000Ware and Controlsuite. and in Motorware there no example code for F28069 for peripheral setup and config. 

    Question: How to include the register level header file (F28069) into motorware based project so I can access to MCU register more directly rather than motorware library syntax representing the peripheral register and bits names (for easier sync with datasheet naming and description). 

  • Richard,

    From your post above, "I note there no F28069 example code in C2000Ware...", we do have SCI example code using the bit-field header files:

    C:\ti\c2000\C2000Ware_<VERSION>\device_support\f2806x\examples\c28\<SCI EXAMPLE CODE>

    Also, in case you are interested, please see the F2806x workshop for details on using the bit-field header file approach:

    https://training.ti.com/c2000-f2806x-microcontroller-workshop?context=1137791-1137782

    As for how to "include the register level header file (F28069) into Mware", I will ask an Mware expert to comment.

    - Ken

  • In C2000Ware there are some drivers for the F2802x that are pretty similar to those used in MotorWare and there are some examples for those that may be close enough to be helpful. They're in device_support\f2802x\examples\drivers\sci*

    Regarding adding the register header files to a MotorWare project, you should be able to follow the steps in the F2806x Firmware Development Guide (in the device support docs folder in C2000Ware called F2806x_DEV_USER_GUIDE.pdf) for creating a new project. Skip to the steps where it describes adding common\include and headers\include to #include search path and the F2806x_Header_nonBIOS.cmd and F2806x_GlobalVariableDefs.c files to the project.

    Whitney