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.

Add SCI to Motorware example project

Other Parts Discussed in Thread: CONTROLSUITE, MOTORWARE

Hello all,

in this thread http://e2e.ti.com/support/microcontrollers/c2000/f/902/t/275198.aspx, it is mention that there is InstaSPIN library for SCI.

Is it different from the one that used in SCI_echoback example for F28069 from ControlSUITE? Where can I find this library and its documentation?

Also there is example ate_comms.zip. What library that used in this example?

I want to add SCI to F28069M (instaSPIN-MOTION) example project from Motorware, which one is easier (I am very new with TI microcontroller and CCS)?

Thanks!

  • There is not an InstaSPIN library for SCI, there are SCI drivers / API created in MotorWare

    C:\ti\motorware\motorware_1_01_00_08\sw\drivers\sci\src\32b\f28x\f2806x

    The easiest way to browse the functions is to use C:\ti\motorware\motorware_1_01_00_08\MotorWare.exe

    and go to Drivers --> API Documentation

    In the MotorWare projects (sw/solutions) we don't have an example of using the SCI (UART) because we typically have JTAG on the controlCARD for development and use SPI or GPIO to talk to power drivers.  On the thread you mention I posted an example (ate_comms.zip) of using UART that we do use on our automated test equipment, just to give an idea of how the SCI is set-up and commands are used.

    I would use the MotorWare APIs to accomplish your goal, NOT the controlSUITE example.

     

  • Another thing to point out is that the MotorWare API style is also being migrated into general C2000 software support and we started this with the F28027 LaunchPad. The drivers for LaunchPad are actually in our exact same drivers repository for MotorWare, so the examples for LaunchPad in controlSUITE will be very helpful in understanding how to add functions like SCI / UART .

    C:\ti\controlSUITE\development_kits\C2000_LaunchPad\f2802x_examples

     

  • Thank you, Chris! This is exactly what I need!

  • Hi Maria, did this work for you? I see that some library functions are missing in the Motorware modules compared to C200 Launchpad modules.

    -Tamil

  • Hello Tamil,

    I haven't tried it yet. Previously I only learned how to configure the registers because I am new in TI microcontroler (how to set the registers manually, and how to adapt them in Motorware).

    Seems that the one in launchpad is easier to be used because we only need to set the registers.

    In Motorware, we can call the functions we need, but indeed some of them are missing (but I don't know in latest Motorware).

    Soon, I will have time to try this SCI. Now I have holiday until next week so I could not try it.

    I will inform you later.

    Meanwhile, hope you can solve your problem.

    Best regards,

    Maria

  • Tamil,

    When I compare the controlSUITE LaunchPad version vs. MotorWare, I see the exact same sci API functions defined. There is only one small difference with one API:

    controlSUITE version:

    void SCI_setTxDelay(SCI_Handle sciHandle, const uint8_t delay)

    MotorWare version:

    void SCI_setTxDelay(SCI_Handle sciHandle, const uint_least8_t delay)

     

    what functions do you think are missing?

  • Thanks for your reply Maria.

    Chris, I have started another thread describing my issue. Thanks for your help.

    -Tamil

  • I too am integrating SCI unto my project through the F28609M control card.

    I am looking at the code from controlsuite and ported over the example the best I could to motorware 12.

    I created interrupt functions for both rx and tx sci interrupts but they never seem to go to them. Both the ate example and the controlsuite example seem to process all sci data in non-interrupt functions. Am I right in saying that?

    I've been pulling my hair to figure out why. Hopefully I can get answer.

    Cristhian

  • Cristhian,

    You're probably missing the code to setup the interrupts in the PIE.  Checkout the section on the PIE in the TRM for this device and then look at the PIE driver in motorware.  You can also look at some of the motorware examples to see how the PIE is setup for other peripherals and then apply this knowlege to SCI.

    Give that a shot first and if you need additional assistance let me know.

    BR,

  • Hello Christian,

    I would like you to check this thread.

    http://e2e.ti.com/support/microcontrollers/c2000/f/902/p/334989/1168654.aspx#1168654

    Hope this helps you.

    Best regards,

    Maria

  • Trey,


    Yes, that was the case. I figured it out an hour after I posted the question. I forgot to enable the PIE. Thanks.


    Cristhian

  • Even after enabling my PIE, my interrupts don't seem to process. My device seems to be halting. Should I bother using interrupts?

    When clearing the interrupt flag, the only on I see cleared it the INT9 group. Why doesn't RXFFINT CLR get used? When I did so, it halted my program. When I attempt to debug on the interrupt, I get no assembly error.

    I've seen examples where all the SCI data processing is done in main loop. Should that be the way to do it?

    Here is my code this far. My GPIOs are set up as GPIO 28 for RX, 29 for TX, no pullups or input qual. The async was giving me a problem:

    void HAL_setupScia(HAL_Handle handle){
    	HAL_Obj *obj = (HAL_Obj *)handle;
    
    	// setup communication mode & parameters - idle-line,115200,8,N,1
    	SCI_setNumStopBits(obj->sciHandle,SCI_NumStopBits_One);		// clr SCICCR bit 7
    	SCI_setParity(obj->sciHandle,SCI_Parity_Odd);				// clr SCICCR bit 6
    	SCI_disableParity(obj->sciHandle);							// clr SCICCR bit 5
    	SCI_disableLoopBack(obj->sciHandle);						// clr SCICCR bit 4
    	SCI_setMode(obj->sciHandle,SCI_Mode_IdleLine);				// clr SCICCR bit 3
    	SCI_setCharLength(obj->sciHandle,SCI_CharLength_8_Bits);	// set SCICCR bits 2..0
    	SCI_setBaudRate(obj->sciHandle,SCI_BaudRate_115_2_kBaud);	// SCIHBAUD:SCILBAUD
    
    	SCI_disable(obj->sciHandle);								// clr SCICTL1 bit 5
    	SCI_enableRx(obj->sciHandle);								// set SCICLT1 bit 0
    	SCI_enableTx(obj->sciHandle);								// set SCICLT1 bit 1
    	SCI_enableRxInt(obj->sciHandle);							// set SCICTL2 bit 1
    //	SCI_enableTxInt(obj->sciHandle);							// set SCICTL2 bit 0
    
    	// set up FIFOs
    	SCI_enableChannels(obj->sciHandle);							// set SCIFFTX bit 15
    	SCI_enableTxFifoEnh(obj->sciHandle);						// set SCIFFTX bit 14
    	SCI_resetTxFifo(obj->sciHandle);							// set SCIFFTX bit 13
    	SCI_disableTxFifoInt(obj->sciHandle);						// clr SCIFFTX bit 5
    	SCI_setTxFifoIntLevel(obj->sciHandle,SCI_FifoLevel_Empty);	// SCIFFTX bits 4..0
    
    	SCI_enableRxFifo(obj->sciHandle);							// set SCIFFRX bit 13
    	SCI_enableRxFifoInt(obj->sciHandle);						// clr SCIFFRX bit 5
    	SCI_setRxFifoIntLevel(obj->sciHandle,SCI_FifoLevel_Empty);	// SCIFFRX bits 4..0
    
    	SCI_setTxDelay(obj->sciHandle,0);
    	SCI_setPriority(obj->sciHandle,SCI_Priority_FreeRun);
    	SCI_enable(obj->sciHandle);									// set SCICTL1 bit 5
    	return;
    } // end of HAL_setupScia() function
    
    void HAL_enableSciaInt(HAL_Handle handle){
    	HAL_Obj *obj = (HAL_Obj *)handle;
    
    	PIE_enableRxInt(obj->pieHandle);		// INT9.1
    	//PIE_enableTxInt(obj->pieHandle);		// INT9.2
    	CPU_enableInt(obj->cpuHandle,CPU_IntNumber_9);	// enable cpu interrupt group for Rx & Tx
    	return;
    } // end of HAL_enableSciaInt() funtion
    
    interrupt void uartRxISR(void){
    	HAL_acqRxInt(halHandle);
    
    	HAL_Obj *obj = (HAL_Obj *)halHandle;
    	uint16_t rxChar = SCI_read(obj->sciHandle);
    	SCI_write(obj->sciHandle,rxChar);
    	rxBuffer[rxBufIndex++] = rxChar;
    
    	return;
    } // end of uartRxISR() function
    
    static inline void HAL_acqRxInt(HAL_Handle handle){
    	HAL_Obj *obj = (HAL_Obj *)handle;
    
    	//SCI_clearRxFifoInt(obj->sciHandle);			// clear fifo interrupt flag from SCIFFRX <- GIVES ERROR AND HALTS
    	//SCI_clearRxFifoOvf(obj->sciHandle);			// clear overflow interrupt flog from SCIFFRX
    	PIE_clearInt(obj->pieHandle,PIE_GroupNumber_9);		// acknowledge interrupt from PIE group 9
    	return;
    }

    Cristhian

  • Cristhian Arbelaez said:

    SCI_enableTxFifoEnh(obj->sciHandle); // set SCIFFTX bit 14


    Not sure 100% but this call somehow prevents Rx interrupt to occur.

    At least, that was what I saw. In my program I only allow Rx int but not Tx int.

  • Tinhtan,


    I ended up scrapping FIFOs and going with straight RX interrupts. Thank you for you response.

    Cristhian

  • Hi Chris ,

    Could you please share me the ate_comms.zip that you mentioned ? Or please email me to yzhan125@gmail.com ?

    I'm currently working on the instaSPIN-FOC development kit, trying to figure out a way to automate test through UART like yous. 

    Thanks,

    Jess

  • it's posted for download here
    e2e.ti.com/.../960726
  • Hi Chris, 

    I'm trying to run the demo on F28027 lunch pad and trying to see if the communication works there. 

    I think the first time it does work and I saw the temperature changing through Putty. But then second time I try, I got lots of error message while compile. 

    It's really confusing, could you please let me know where it went wrong? I attached error and compile properties in below: 

  • You're seeing this error because the .econst section is not large enough to handle the data you're trying to place into it. You're trying to place 0x10EB bytes into a memory block of size 0x800 bytes. You can edit the 28027_RAM_lnk.cmd file to increase the size of the memory block you're placing .econst into, or move the .econst section to a bigger block of memory.

    Sean
  • Hi Sean,

    1) if I change the 28027_RAM_lnk.cmd, when other project use this file, it will change the memory as well, right ?
    A little confusion here is I do see it's work at first time , if it's the memory issue, should it be not work at all ?

    2) not sure how can i change it like your suggestion , could you please give me specific instruction in the following 28027_RAM_lnk.cmd?

    /*
    // TI File $Revision: /main/5 $
    // Checkin $Date: July 6, 2009 17:18:44 $
    //###########################################################################
    //
    // FILE: 28027_RAM_lnk.cmd
    //
    // TITLE: Linker Command File For 28027 examples that run out of RAM
    //
    // This ONLY includes all SARAM blocks on the 28027 device.
    // This does not include flash or OTP.
    //
    // Keep in mind that L0 is protected by the code
    // security module.
    //
    // What this means is in most cases you will want to move to
    // another memory map file which has more memory defined.
    //
    //###########################################################################
    // $TI Release: DSP2802x Header Files Internal Release 2 $
    // $Release Date: July 15, 2008 $
    //###########################################################################
    */

    /* ======================================================
    // For Code Composer Studio V2.2 and later
    // ---------------------------------------
    // In addition to this memory linker command file,
    // add the header linker command file directly to the project.
    // The header linker command file is required to link the
    // peripheral structures to the proper locations within
    // the memory map.
    //
    // The header linker files are found in <base>\DSP2802x_headers\cmd
    //
    // For BIOS applications add: DSP2802x_Headers_BIOS.cmd
    // For nonBIOS applications add: DSP2802x_Headers_nonBIOS.cmd
    ========================================================= */

    /* ======================================================
    // For Code Composer Studio prior to V2.2
    // --------------------------------------
    // 1) Use one of the following -l statements to include the
    // header linker command file in the project. The header linker
    // file is required to link the peripheral structures to the proper
    // locations within the memory map */

    /* Uncomment this line to include file only for non-BIOS applications */
    /* -l DSP2802x_Headers_nonBIOS.cmd */

    /* Uncomment this line to include file only for BIOS applications */
    /* -l DSP2802x_Headers_BIOS.cmd */

    /* 2) In your project add the path to <base>\DSP2802x_headers\cmd to the
    library search path under project->build options, linker tab,
    library search path (-i).
    /*========================================================= */

    /* Define the memory block start/length for the DSP2802x
    PAGE 0 will be used to organize program sections
    PAGE 1 will be used to organize data sections

    Notes:
    Memory blocks on F28027 are uniform (ie same
    physical memory) in both PAGE 0 and PAGE 1.
    That is the same memory region should not be
    defined for both PAGE 0 and PAGE 1.
    Doing so will result in corruption of program
    and/or data.

    The L0 memory blocks is mirrored - that is
    it can be accessed in high memory or low memory.
    For simplicity only one instance is used in this
    linker file.

    Contiguous SARAM memory blocks can be combined
    if required to create a larger memory block.
    */

    MEMORY
    {
    PAGE 0 :
    /* For this example, L0 is split between PAGE 0 and PAGE 1 */
    /* BEGIN is used for the "boot to SARAM" bootloader mode */

    BEGIN : origin = 0x000000, length = 0x000002
    RAMM0 : origin = 0x000050, length = 0x0003B0
    PRAML0 : origin = 0x008000, length = 0x000900
    RESET : origin = 0x3FFFC0, length = 0x000002

    IQTABLES : origin = 0x3FE000, length = 0x000B50 /* IQ Math Tables in Boot ROM */
    IQTABLES2 : origin = 0x3FEB50, length = 0x00008C /* IQ Math Tables in Boot ROM */
    IQTABLES3 : origin = 0x3FEBDC, length = 0x0000AA /* IQ Math Tables in Boot ROM */

    BOOTROM : origin = 0x3FF27C, length = 0x000D44


    PAGE 1 :

    /* For this example, L0 is split between PAGE 0 and PAGE 1 */
    BOOT_RSVD : origin = 0x000002, length = 0x00004E /* Part of M0, BOOT rom will use this for stack */
    RAMM1 : origin = 0x000400, length = 0x000400 /* on-chip RAM block M1 */
    DRAML0 : origin = 0x008900, length = 0x000700
    }


    SECTIONS
    {
    /* Setup for "boot to SARAM" mode:
    The codestart section (found in DSP28_CodeStartBranch.asm)
    re-directs execution to the start of user code. */
    codestart : > BEGIN, PAGE = 0
    ramfuncs : > RAMM0 PAGE = 0

    #ifdef __TI_COMPILER_VERSION__
    #if __TI_COMPILER_VERSION__ >= 15009000
    .TI.ramfunc : {} > RAMM0, PAGE = 0
    #endif
    #endif

    .text : > PRAML0, PAGE = 0
    .cinit : > RAMM0, PAGE = 0
    .pinit : > RAMM0, PAGE = 0
    .switch : > RAMM0, PAGE = 0
    .reset : > RESET, PAGE = 0, TYPE = DSECT /* not used, */

    .stack : > RAMM1, PAGE = 1
    .ebss : > DRAML0, PAGE = 1
    .econst : > DRAML0, PAGE = 1
    .esysmem : > RAMM1, PAGE = 1

    IQmath : > PRAML0, PAGE = 0
    IQmathTables : > IQTABLES, PAGE = 0, TYPE = NOLOAD

    /* Uncomment the section below if calling the IQNexp() or IQexp()
    functions from the IQMath.lib library in order to utilize the
    relevant IQ Math table in Boot ROM (This saves space and Boot ROM
    is 1 wait-state). If this section is not uncommented, IQmathTables2
    will be loaded into other memory (SARAM, Flash, etc.) and will take
    up space, but 0 wait-state is possible.
    */
    /*
    IQmathTables2 : > IQTABLES2, PAGE = 0, TYPE = NOLOAD
    {

    IQmath.lib<IQNexpTable.obj> (IQmathTablesRam)

    }
    */
    /* Uncomment the section below if calling the IQNasin() or IQasin()
    functions from the IQMath.lib library in order to utilize the
    relevant IQ Math table in Boot ROM (This saves space and Boot ROM
    is 1 wait-state). If this section is not uncommented, IQmathTables2
    will be loaded into other memory (SARAM, Flash, etc.) and will take
    up space, but 0 wait-state is possible.
    */
    /*
    IQmathTables3 : > IQTABLES3, PAGE = 0, TYPE = NOLOAD
    {

    IQmath.lib<IQNasinTable.obj> (IQmathTablesRam)

    }
    */

    }

    /*
    //===========================================================================
    // End of file.
    //===========================================================================
    */
  • Did you add any additional constants, such as an array of values? Either way, if you look at the memory map, you'll see that you have a specific amount of RAM to work with. Here, it's broken up into 3 sections: RAMM1, RAMM0, and DRAML0. You'll see that RAMM0 and DRAML0 are continuous, i.e. you can pull from one to increase the other. You'll see that RAMM0 starts at 0x8000 and has length of 0x900; furthermore, DRAML0 starts at 0x8900 (0x8000+0x900 from RAMM0), and has length of 0x700 (ending at 0x9000). You can reduce the size of RAMM0 (by decreasing it's length), and reassign a new starting address to DRAML0 equal to what you took from RAMM0.

    In general, you can see what you have available overall on page 46 of this document: www.ti.com/.../sprs523k.pdf

    You'll see that RAMM0 and DRAML0 effectively cover the whole "L0 SARAM (4K x 16)" block of RAM starting from 0x8000. You can allocate that however you'd like. And yes, any other project that links to this linker command file will have the same memory allotments made. You can create a .cmd file specifically for one project if you'd like.

    Sean