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.

C Programing Language Doccumentation

Other Parts Discussed in Thread: CONTROLSUITE

Hello everyone

I recently acquired a F28027 Piccolo USB Stick, and i find it to be a great development platform. However, I do have a problem, which i guess relates more to the actual programming than the piccolo itself.

Where is, if it exists, the documentation regarding the implementation of the C Programming Language. More precise, where do i find a description of which functions that are implemented, and where they are contained? I have been unable to find any technical documents in the TI webside, that clears up this for me.

I am experienced with the C Programming Language from "normal" computer programming and a small bit of MCU programming a few years ago, and there i used a function sleep(), in order to stall the processor for a number of (micro)seconds. Say i want to find out if this function is implemented in the C standard used with the Piccolo MCUs, where do i then turn? Solving the problem of not knowing where to look, i wrote a small function myself, that initiates a CPUtimer and counts up to a certain number, but i would assume that more general functions are described somewhere? A good example of what i am looking for, is the "math_mdl.pdf" file, included with the math library.

Do the documentation i ask for even exist, or is it simply because there are no "general" functions implemented, other than the ones provided by libraries? Sometimes, the documentation is kept as comments in the various header files you include in your code, but i do not find any "general" libraries included. Only product specific files, like "DSP2802x_Comp.h", which is included in PeripheralHeaderIncludes.h.

I hope you guys will be able to answer my question, and point me to some documentation, or other usable information.

 

Best Regards

Peter C.

  • Hi Peter

    From what I can recall "sleep()" is a OS (operating system) API function. There is no such functionality in TI's  C implementation that I know of (I may be wrong).

    One possible solution is to used US_DELAY macro, which is included in DSP's Preipheral header files and examples - check the ADC example code. Thou it works, you must be warned, that this code actually executes a loop for n-times in order to achieve desired delay. If some interrupt happens within the loop, the delay will thus be longer for a interrupt processing time. Not an accurate way to generate delays.

    The other possibility is to use a RTOS package (DSP/BIOS comes to mind), which provides such an API call

    For the documentation check the following documents: SPRU514C and SPRU625

    I hope this helps

     

    Regards, Mitja

  • Hey Mitja


    Thank you for taking the time to answer my questions. I have found some of what i was searching for, in SPRU514, in which there is a chapter called "TMS320C28x C/C++ Language Implementation". This chapter explains alot about e.g. datatypes that is useful if you don't have that much experience with programming C for MCUs. I was unable to find the "US_DELAY" macro you are talking about, so for now i'll stick to the solution I'm using, with a timer and a loop.

    I have another question which i don't think is touched that much by the documentation: Interrupts. The topic is somewhat covered in SPRU514, but i have no idea of how to actually implement interrupt handling, since there are no examples. For instance, when a timer generates an interrupt, i would like to run the function interrupt_function1(). From what i read, you need to implement the function like

    #pragma INTERRUPT (interrupt_handler);

    interrupt void interrupt_handler()
    {
    unsigned int flags;
    ...
    }

    SPRUFN3C ( TMS320F2802x/TMS320F2802xx Piccolo System Control and Interrupts) tells a lot about interrupts and how they work, and it is clear that somehow you need to specify which code to run when the different interrupts are raised. But i have no idea how to do that. I can't find any examples in the code examples, that uses CPU interrupts.. Have i missed something? Where can i find info on this?

    best regards

    Peter C

  • Hi Peter

    Sorry about the name of the delay macro. it is DELAY_US and NOT the US_DELAY (I make this kind of mistakes happen a lot lately). The function it calls is in the "DSP2802x_usDelay.asm", while the macro is define in "DSP2802x_Examples.h".

     

    Regarding the interrupts I found that the best example of interrupt code is in "Example_2802xCpuTimer.c". You can see how the interrupt function address is put in PIE vector table (lines 112-114), how the interrupt is enabled within PIE (line 164), how different interrupts are enabled within the CPU (lines 159-161) and how interrupts are enabled globally (line 167).

    When you cover this we can further discuss the ERTM instruction (line 168) and its impact on debugging.

    One other thing. If you use interrupt keyword with function declaration, you do not need to use #pragma extension. It is one or the other.

     

    Hope this helps, Mitja

  • Peter,

    You can download the examples Mitja mentions here:

    http://focus.ti.com/docs/toolsw/folders/print/sprc832.html

    -Lori

  • For Piccolo, I recommend our new controlSUITE

    www.ti.com/controlSUITE

    Once you install and select the F2802x series (and I recommend the controlSTICK as well) you'll find DSP2802x_usDelay.asm here:

    C:\ti\ControlSUITE\device_support\f2802x\v125\DSP2802x_common\source

     

  • Hello everyone

     

    Thank your for your answers.I will look at the delay system ASAP, but for now i'll just use the one i created. I do however find it a bit confusing, that there are several example collections. On the CD  that came with the stick, there are 2 examples "simpleDACtoADC" and "blinkingLED". Then i found another example library, which included comparator, ADC and PWM examples(installs to the same path as the one from the stick: c:\Texas Instruments\Piccolo controlSTICK\). And now i found a third one, which i guess are the ones you talk about, which installs to C:\tidcs\c28\DSP2802x\v121, and is called "DSP2802x header files and examples".  I'll try to install the controlSUITE program and see what comes from that.

    Best regards

    Peter

  • Peter,

    I understand your confusion.

    Your Piccolo controlSTICK CD only comes with the simple DAC to ADC and LED demo.  After this tool was released we created more examples that we placed on the website. (it looks like you found those).

     

    When we release a device series we also include a set of Header Files and Code Examples that work agnostic of any of our development tools.  For F2802x this is here: http://focus.ti.com/docs/toolsw/folders/print/sprc832.html

     

    What we are doing as of yesterday with our controlSUITE announcement is giving customers a single place to go for all their software needs.  The controlSUITE installer will always show you everything that's available for a given device or development tool, and it re-organizes everything into a common file structure.  This will ensure that what you went through doesn't happen again. You will always know WHAT is available, and you will always have the latest collateral and revisions as soon as we place them on our server.  

    http://www.ti.com/controlsuite