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.

first programm tms320 f28069 (beginner)

Other Parts Discussed in Thread: CONTROLSUITE

Hi :)

i'm beginner.

I had read the manuals
and now I'm trying to change with the programs.
I want to try to change the main for "flashing LED".

this is my code:

"

#include "FlashingLeds-Settings.h"
#include "PeripheralHeaderIncludes.h"
int i;
void main(void)
{
//=================================================================================
// INITIALIZATION - General
//=================================================================================
//-------------------------------- FRAMEWORK --------------------------------------
CpuTimer0Regs.PRD.all =  mSec1; // A tasks
CpuTimer1Regs.PRD.all =  mSec50; // B tasks
CpuTimer2Regs.PRD.all =  mSec500; // C tasks
i = 0;
CpuTimer2Regs.TCR.bit.TIF = 1;
while(1)
{
if(CpuTimer2Regs.TCR.bit.TIF == 1)
  {
CpuTimer2Regs.TCR.bit.TIF = 1; // clear flag
GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // toggle GPIO34 which controls LD3 on most controlCARDs
i = i+1;
if (i == 10)
{
GpioDataRegs.GPATOGGLE.bit.GPIO31 = 1;
i = 0;
}
}
}
} //END MAIN CODE
""
 i dont understand the error :( 
  • Beginner_phill,

    What error are you getting when you try to compile the code you posted above? Feel free to post a screenshot from CCS.

    Kyle
  • the structure of my program "prova led" :

  • A few questions to help clarify.

    1) I see you included F2806x_CpuTimers.c in your project folder called Prova led. In addition you also have your main.c file. This could be the case of where you have two main() functions in the same project folder which could cause issues when trying to compile and debug. So do both .c files have a main() function.
    2) I can also see that you created a new .ccxml target configuration file. Could you show me a picture of what your configuration looks like? If you reused an example project, this new target configuration file may not be necessary, but I would be ok with taking a look at it anyway.
    3) From a programming standpoint, it looks like you are trying to toggle GPIO34 a total of 10 times. If that's the case, you may want to consider using a for loop to increment. On the other hand, you could implement the toggle as part of an ISR in which case you could move the toggle logic to the ISR function call.

    Let me know what you decide to do and please let me know if you have any additional questions.

    Kyle
  • 1) in other examples,  i saw it's possibie puting two  files  .c.   it's no possible? 

    this is file F2806x_CputTimers.c: 

    #include "F2806x_Device.h" // Headerfile Include File
    #include "F2806x_Examples.h" // Examples Include File


    struct CPUTIMER_VARS CpuTimer0;
    struct CPUTIMER_VARS CpuTimer1;
    struct CPUTIMER_VARS CpuTimer2;

    //---------------------------------------------------------------------------
    // InitCpuTimers:
    //---------------------------------------------------------------------------
    // This function initializes all three CPU timers to a known state.
    //
    void InitCpuTimers(void)
    {
    // CPU Timer 0
    // Initialize address pointers to respective timer registers:
    CpuTimer0.RegsAddr = &CpuTimer0Regs;
    // Initialize timer period to maximum:
    CpuTimer0Regs.PRD.all = 0xFFFFFFFF;
    // Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
    CpuTimer0Regs.TPR.all = 0;
    CpuTimer0Regs.TPRH.all = 0;
    // Make sure timer is stopped:
    CpuTimer0Regs.TCR.bit.TSS = 1;
    // Reload all counter register with period value:
    CpuTimer0Regs.TCR.bit.TRB = 1;
    // Reset interrupt counters:
    //CpuTimer0.InterruptCount = 0;


    // Initialize address pointers to respective timer registers:
    CpuTimer1.RegsAddr = &CpuTimer1Regs;
    CpuTimer2.RegsAddr = &CpuTimer2Regs;
    // Initialize timer period to maximum:
    CpuTimer1Regs.PRD.all = 0xFFFFFFFF;
    CpuTimer2Regs.PRD.all = 0xFFFFFFFF;
    // Initialize pre-scale counter to divide by 1 (SYSCLKOUT):
    CpuTimer1Regs.TPR.all = 0;
    CpuTimer1Regs.TPRH.all = 0;
    CpuTimer2Regs.TPR.all = 0;
    CpuTimer2Regs.TPRH.all = 0;
    // Make sure timers are stopped:
    CpuTimer1Regs.TCR.bit.TSS = 1;
    CpuTimer2Regs.TCR.bit.TSS = 1;
    // Reload all counter register with period value:
    CpuTimer1Regs.TCR.bit.TRB = 1;
    CpuTimer2Regs.TCR.bit.TRB = 1;
    // Reset interrupt counters:
    //CpuTimer1.InterruptCount = 0;
    //CpuTimer2.InterruptCount = 0;

    }

    //---------------------------------------------------------------------------
    // ConfigCpuTimer:
    //---------------------------------------------------------------------------
    // This function initializes the selected timer to the period specified
    // by the "Freq" and "Period" parameters. The "Freq" is entered as "MHz"
    // and the period in "uSeconds". The timer is held in the stopped state
    // after configuration.
    //
    void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period)
    {
    Uint32 PeriodInClocks;

    // Initialize timer period:
    Timer->CPUFreqInMHz = Freq;
    Timer->PeriodInUSec = Period;
    PeriodInClocks = (long) (Freq * Period);
    Timer->RegsAddr->PRD.all = PeriodInClocks - 1; // Counter decrements PRD+1 times each period

    // Set pre-scale counter to divide by 1 (SYSCLKOUT):
    Timer->RegsAddr->TPR.all = 0;
    Timer->RegsAddr->TPRH.all = 0;

    // Initialize timer control register:
    Timer->RegsAddr->TCR.bit.TSS = 1; // 1 = Stop timer, 0 = Start/Restart Timer
    Timer->RegsAddr->TCR.bit.TRB = 1; // 1 = reload timer
    Timer->RegsAddr->TCR.bit.SOFT = 0;
    Timer->RegsAddr->TCR.bit.FREE = 0; // Timer Free Run Disabled
    Timer->RegsAddr->TCR.bit.TIE = 1; // 0 = Disable/ 1 = Enable Timer Interrupt

    // Reset interrupt counter:
    Timer->InterruptCount = 0;

    }

    //===========================================================================
    // End of file.
    //===========================================================================

  • 2)  my ccxml configuration f

  • 3) yes, i want to toggle GPIO34 and then toogle GPIO31. I used a while (1) loop. it's the same of for (;;) loop i think. it's correct?
  • Yes, it is certainly ok to have more than one .c file. However, the issue arises if there is more than one main() function across all the .c files included in a single project folder. You may want to double check to make sure only more main() function exists.
  • In your target configuration file, you should probably switch to using XDS100v2 probe. That is the preferred debug probe to use.
  • And in response to your coding question, yes the for( ; ; ) and while(1) statements are essentially the same. Both create infinite loops.
  • Also,

    Where did you get the starter files that you are working with? Did you pull them from controlSUITE?
  • well.... you can try my program on your device please ? :)
  • you can try my program on your device please? :)
  • I will see if I can replicate the error messages on my machine and I will let you know. Keep me posted with any updates.
  • if(CpuTimer2Regs.TCR.bit.TIF == 1)

     {

    CpuTimer2Regs.TCR.bit.TIF = 1; // clear flag

    setting to 1 clears it? I am not checked the data sheet but generally 0 clears.

  • thanks for you suggestion. but it's no problem i think :)

    so... i changed my programm and now the error is:
    ""C:/ti/controlSUITE/device_support/f2806x/v151/F2806x_headers/include/F2806x_Device.h", line 79: error #41: expected an identifier"


    at 79 line, i have this code:
    "extern __cregister volatile unsigned int IFR; "