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 driver sample code / documentation

Other Parts Discussed in Thread: CONTROLSUITE, MOTORWARE

Hi,

I'm struggling to make use of the SCI driver class of the InstaSPIN library in order to read and write data from and to the UART of my F28069. Is there anyone who accomplished that and can post me some sample code? Or have I just not found the right documentation. I did not find more than the docxygen output. The sci_echoback sample of the controlSUITE library works. I try to do all the steps done there with the appropriate SCI_xxx functions, without success. The blue LEDs on the controlCARD remain dark while there is data written into the TX register, so it does not seem to be a receiving problem on the client(PC) side.

Thanks in advance!

  • Christian,

    Recall that the on controlCARD emulator has a secondary UART channel, it's possible there is a conflict there. However, if you have the controlSUITE code for SCI working I doubt that's the issue.

    I'll assume you are already using MotorWare.exe to browse the documenation under Drivers --> API Documentation --> Modules --> SCI

    We the motor projects we don't use the UART very often on a day to day basis, but we are using it in our automated test equipment (ATE) system. Here I've attached a zip file that includes a module called "ate_comms".  This module uses the UART MotorWare SCI_xxx APIs.  I hope this will help you debug.

     

    ate_comms.zip
  • Christian,

    Also remember you'll need to setup the GPIO separately using the GPIO APIs.

  • Thanks Chris, Thanks Trey,

    for your time. It was mainly a beginners error: I had to realize the concept of mapping the controller's registers into the sci struct first, so this was the crucial change:

    SCI_init((void *)SCIA_BASE_ADDR, sizeof(SCI_Obj));

    Sorry for that...

  • Dear all,

    I am new to Instaspin. I already gone through to lab example. i want to implement SCI-A and SCI-B communication for my own board software for 28069F. There is no any example code of SCI in motorware. Have you any reference code for this for start up my implementation? its really very helpful to me.

  • Hello, 

    I am new too and I had the similar question before.

    This was the thread that I posted:

    http://e2e.ti.com/support/microcontrollers/c2000/f/902/p/279598/976170.aspx#976170

    Hope this is helpful for you to start. So far I have success to have SCI communication in Motorware project.

    If you are also new in TI microcontroller just like me, you also can see SCI example in \controlSUITE\device_support\f2806x\v136\F2806x_examples_ccsv5\sci_echoback. In this case, you need to install controlSUITE in your PC.

    Hope this helps.

    Best regards,

    Maria

  • Dear all,

    Thank you for your reply.

    I gone through this thread and based I implement SCI B communication and added new function which not available in motorware. But I face some problem regarding interrupt generation. SCI B received interrupt generated only once time and then not generating interrupt regular. I think still something missing in my code. Here I snap of my code. If you have any idea please help.

    DRV_Handle DRV_init(void *pMemory,const size_t numBytes)

    {

    ………………

    obj->sciaHandle = SCI_init((void *) SCIA_BASE_ADDR, sizeof(SCI_Obj));

    obj->scibHandle = SCI_init((void *) SCIB_BASE_ADDR, sizeof(SCI_Obj));

    }

    void DRV_setupscib(DRV_Handle handle)

    {

    DRV_Obj *obj = (DRV_Obj *)handle;

    // Initiate SCI reset

    SCI_enable(obj->scibHandle);

    SCI_reset(obj->scibHandle);

    SCI_enable(obj->scibHandle);

    // Initialize SCI Comm. Control Register

    SCI_setCharLength(obj->scibHandle,SCI_CharLength_8_Bits);

    SCI_setMode(obj->scibHandle,SCI_Mode_IdleLine);

    SCI_disableLoopBack(obj->scibHandle);

    SCI_enableParity(obj->scibHandle);

    SCI_setParity(obj->scibHandle,SCI_Parity_Odd);

    SCI_setNumStopBits(obj->scibHandle,SCI_NumStopBits_One);

    // Initialize SCI Control Register 1

    SCI_enableRx(obj->scibHandle);

    SCI_enableTx(obj->scibHandle);

    SCI_disableSleep(obj->scibHandle);

    SCI_disableTxWake(obj->scibHandle);

    SCI_disableRxErrorInt(obj->scibHandle);

    // Select Baud Rate

    SCI_setBaudRate(obj->scibHandle,SCI_BaudRate_9600_Baud);

    // Initialize SCI Control Register 2

    SCI_disableTxInt(obj->scibHandle);

    SCI_enableRxInt(obj->scibHandle);

    // Initialize SCI Priority Control Register

    SCI_setPriority(obj->scibHandle,SCI_Priority_FreeRun);

    SCI_setPriority(obj->scibHandle,SCI_Priority_AfterRxRxSeq);

    // Initialize SCI Tx & Rx FIFO Register

    SCI_disableTxFifoEnh(obj->scibHandle);

    return;

    } // end of DRV_setupscib() function

    /************************************************************/

    void DRV_enablesciints(DRV_Handle handle)

    {

    DRV_Obj *obj = (DRV_Obj *)handle;

    PIE_enablesciInt(obj->pieHandle);

    // enable the cpu interrupt for SCI A & B interrupts

    CPU_enableInt(obj->cpuHandle,CPU_IntNumber_9);

    return;

    } // end of DRV_enablesciints() function

    /************************************************************/

    void PIE_enablesciInt(PIE_Handle pieHandle)

    {

    PIE_Obj *pie = (PIE_Obj *)pieHandle;

    uint16_t index;

    index = 8;

    pie->PIEIER_PIEIFR[index].IER |= 1; //SCIRXINTA

    pie->PIEIER_PIEIFR[index].IER |= 1<<1; //SCITXINTA

    pie->PIEIER_PIEIFR[index].IER |= 1<<2; //SCIRXINTB

    pie->PIEIER_PIEIFR[index].IER |= 1<<3; //SCITXINTB

    return;

    } // end of PIE_enableAdcInt() function

    /************************************************************/

    interrupt void SCIRXINTB_ISR(void) // SCI-B

    {

    DSXM;

    scib_rx_interupt_service(); //data received routine

    SXM;

    DRV_acqsciInt(drvHandle);

    }

    /*********************************************************/

    static inline void DRV_acqsciInt(DRV_Handle handle)

    {

    DRV_Obj *obj = (DRV_Obj *)handle;

    // Acknowledge interrupt from PIE group 10

    PIE_clearInt(obj->pieHandle,PIE_GroupNumber_9);

    return;

    } // end of DRV_acqsciInt() function

  • Hello,
    Have you pointed SCIRXINTB_ISR in DRV_initIntVectorTable() in drv.h?

    I have tried your setting in my code and nothing seemed wrong.
    Except I don't know what DSXM and SXM are and my CCS doesn't find their definitions.


    Did you put counter on your SCIRXINTB_ISR interrupt and see the value to know whether it was called or not when an input came?

    And maybe this is hardware problem so you must check again the connection.

    And check also the GPIO setting.

    Hope you can solve your problem soon.

    Best regards,

    Maria

  • Thank you maria,

    Resolve the problem.

    Suprit