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/LAUNCHXL-F28379D: how to define a variable on flash memory ?

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hello all,

I have the launchxl-f28379d board . Now I have some question.

1 . How to define a variable on flash memory ? 

2 . After I define a variable on flash memory how to watch that variable on debug window ?

3 . How to clear flash memory of launchxl-f28379d on debug window ?

Thanks & Regards .

  • Sms,

    For questions 1 and 2 please see the F28379D workshop at:

    https://training.ti.com/c2000-f2837xd-microcontroller-workshop

    For question 3, in the Edit view under Target Configurations, select Launch Selected Configuration.  Then in the Debug view connect to the target.  Select Tools -> On-Chip Flash and proceed to Erase Flash.

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken

  • Thank you for helping,

    But I don't know how to define a variable on flash memory.

    I read workshop for launchxl-f28379d , but I don't know how to define a variable on flash memory.

    Please explain more.

    Thanks & regards.

  • Sms,

    You cannot modify or change a variable in flash.  During run-time the code needs to be copied to RAM.  This is done with a memcpy() function.  In the workshop you will notice that this function is being used in the Lab 10 exercise in Main_10.c and Cla_10.c.  For an additional resource, see the following application report:

    http://www.ti.com/lit/spra958

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken

  • Thank you for rsponse,

    In fact I write the below code and receive a voltage from ADC (Analog to Digital Converter) and then save the result on adc0 (and adc1,adc2,adc3). when disconnect the board from laptop the result of ADC that save on adc0 (and adc1,adc2,adc3) removed. But I want to this variable not removed.

    How to define this variable that not removed after disconnect the board from laptop ?

    #include "F28x_Project.h"
    
    
    
    
    uint16_t adc0[100],adc1[100],adc2[100],adc3[100];  // result of adc conversion
    uint16_t i=0;
    
    void configuretimer1 (void);
    void configureADC (void);
    interrupt void adca1_isr (void);
    void main(void)
    {
        InitSysCtrl();
        DINT;  // disable global interrupt
        InitPieCtrl();
    //    IER = 0x0000;
    //    IFR = 0x0000;
        InitPieVectTable();
    
        configureADC();
        configuretimer1();
    
        EALLOW;
        PieVectTable.ADCA1_INT = &adca1_isr;
        EDIS;
        PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
        IER |= M_INT1; //Enable group 1 interrupts
        EINT;
    
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
        PieCtrlRegs.PIEIER1.bit.INTx1 = 1;
    
        while(1);
    
    }
    
    
    
    void configuretimer1 (void)
    {
        CpuTimer1Regs.TCR.bit.TIE = 1; // enable timer1 interrupt
        CpuTimer1Regs.TCR.bit.FREE = 1; // FREE:SOFT = 3 for free runs
        CpuTimer1Regs.TCR.bit.SOFT = 1;
        CpuTimer1Regs.TPRH.bit.TDDRH = 0; // TDDRH:TDDR = 9 ----> prescaler = 10
        CpuTimer1Regs.TPR.bit.TDDR = 9;
        CpuTimer1Regs.PRD.all = 100; // 5000 nsec = 5usec
        CpuTimer1Regs.TCR.bit.TSS = 0; // start counting
    }
    
    void configureADC (void)
    {
        EALLOW;
        AdcaRegs.ADCCTL2.bit.PRESCALE = 6;    // ADCCLK = input clock/4
        AdcbRegs.ADCCTL2.bit.PRESCALE = 6;    // ADCCLK = input clock/4
        AdccRegs.ADCCTL2.bit.PRESCALE = 6;    // ADCCLK = input clock/4
        AdcdRegs.ADCCTL2.bit.PRESCALE = 6;    // ADCCLK = input clock/4
    
        AdcSetMode(ADC_ADCA, ADC_RESOLUTION_16BIT, ADC_SIGNALMODE_DIFFERENTIAL);
        AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
        AdcSetMode(ADC_ADCC, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
        AdcSetMode(ADC_ADCD, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
    
        AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion
        AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion
        AdccRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion
        AdcdRegs.ADCCTL1.bit.INTPULSEPOS = 1; //Interrupt pulse generation occurs at the end of the conversion
    
        AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;  // power on ADCA
        AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;  // power on ADCB
        AdccRegs.ADCCTL1.bit.ADCPWDNZ = 1;  // power on ADCC
        AdcdRegs.ADCCTL1.bit.ADCPWDNZ = 1;  // power on ADCD
    
        DELAY_US(1000); //////////////////////delay for 1ms to allow ADC time to power up
    
        AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2;  // SOC0 will convert ADCINA2 - ADCINA3
        AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2;  // SOC0 will convert ADCINB2
        AdccRegs.ADCSOC0CTL.bit.CHSEL = 2;  // SOC0 will convert ADCINC2
        AdcdRegs.ADCSOC0CTL.bit.CHSEL = 2;  // SOC0 will convert ADCIND2
    
        AdcaRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec
        AdcbRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec
        AdccRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec
        AdcdRegs.ADCSOC0CTL.bit.ACQPS = 19; // acquisition window = 100 nsec
    
        AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 2;
        AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 2;
        AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 2;
        AdcdRegs.ADCSOC0CTL.bit.TRIGSEL = 2;
    
        AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0;//end of SOC0 will set ADCINT1 flag
    
        AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1;  //enable INT1 flag
    
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;//make sure INT1 flag is cleared
    
        EDIS;
    }
    
    
    interrupt void adca1_isr (void)
    {
    
        adc0[i] = AdcaResultRegs.ADCRESULT0;
        adc1[i] = AdcbResultRegs.ADCRESULT0;
        adc2[i] = AdccResultRegs.ADCRESULT0;
        adc3[i++] = AdcdResultRegs.ADCRESULT0;
    
        if (i == 100)
        {
            asm("  ESTOP0");
        }
        AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;
    
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    
    }
    

    I'm very sorry for elementary Questions. I'm a novice on DSP.

    Thank you very much for helping.

    All the best for you.

  • Hi,

    If you need to store any data in Flash at run time to have it available after a power cycle, you need to program that data in to Flash using Flash API library functions.

    Flash API guide:  http://www.ti.com/lit/pdf/spnu629

    Helpful Flash API wiki: http://processors.wiki.ti.com/index.php/C2000_Flash_FAQ

    Flash API usage example is available in C2000Ware at: C:\ti\c2000\C2000Ware_x_xx_xx_xx\device_support\f2837xd\examples\dual\flash_programming

    Thanks and regards,
    Vamsi