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.

Code not wroking while booting up from Flash- 6713 DSK



Hi Guys,
I have 6713 DSK attached with ADC which is sampling signal with maximum frequency 150 kHz then computing FFT. I burn all the codes to boot from Flash and it is working quite fine. After FFT I am writing FFT values to Flash memory.
For some reason, I am not getting the correct FFT peak from the values saved in Flash. I am sampling 10 kHz signal and the peak shows as it was 50 kHz signal. When I run the same code with CCS, it shows the peak at right sample i.e., 10 kHz.
I am wondering what is causing the change of sampling frequency while booting up from Flash ?
I will appreciate if some one comment on this issue.
Regards,

Tariq

  • Al Salam,

    Watch clkout2 or clkout3 while running using CCS vs Flash.  It may tell if the device is under-run when booting from Flash due to some missing initialization.

    Good Luck,

    Sam

  • Walaikum as Salam,

    Where can I check clkout2 and clkout3 ?

  • On your C6713 DSK, R25 runs clkout2 and R26 runs clkout3.

  • They are also on J1 pin 5 for clkout3 and pin 80 for clkout2.

  • Sam,

    I checked clkout3 and clkout2. They are running with the same speed with CCS and Flash.

    clkout3 = 6.25 MHz

    clkout2 = 25 MHz

    Any other suggestions ?

  • Greetings,

    Can you share with me the Gel file you use under CCS, please.  Your issue is likely between init_emif and init_pll.

    Sam

  • Sam,

    I figured out that ADC's sampling frequency is changing when booting from Flash. For example, I set the sampling frequency to 351 kHz but when measured the ADC's clock while booting from Flash, it was showing 77 kHz. Just to make sure that it is running the same code, I checked with different sampling frequencies and realized that every time it is dividing the sampling frequency with 4 then showing the peak according to the this 'new' sampling frequency.

    I will share the GEL file soon.

    Thanks for your precious time.

    BAS

  • Sam,

    Here attached GEL file.

    /*--------------------------------------------------------------*/
    /* DSK6713.gel                                                  */
    /* Version 3.00                                                 */
    /*                                                              */
    /* This GEL file is designed to be used in conjunction with     */
    /* CCS 3.X and the TMS320C6713 based DSK.                       */
    /*                                                              */
    /*--------------------------------------------------------------*/

    /*--------------------------------------------------------------*/
    /* StartUp()                                                    */
    /* This function is called each time CCS is started.            */
    /* Customize this function to perform desired initialization.   */
    /*--------------------------------------------------------------*/
    StartUp()
    {
        setup_memory_map();

        /*------------------------------------------------------*/
        /* Uncomment the OnTargetConnect() call for CCS 2.X     */
        /* support.                                             */
        /*                                                      */
        /*                                                      */
        /*------------------------------------------------------*/
        //OnTargetConnect();
    }

    /*--------------------------------------------------------------*/
    /* OnTargetConnect()                                            */
    /* This function is called by CCS when you do Debug->Connect on */
    /* CCS 3.X.  When using CCS 2.X, the OnTargetConnect() call     */
    /* should be uncommented from the StartUp() function.           */
    /*--------------------------------------------------------------*/
    OnTargetConnect()
    {
        /*------------------------------------------------------*/
        /* GEL_Reset() is used to deal with the worst case      */
        /* senario of unknown target state.  If for some reason */
        /* a reset is not desired upon target connection,       */
        /* GEL_Reset() may be removed and replaced with         */
        /* something "less brutal" like a cache initialization  */
        /* function.                                            */
        /*------------------------------------------------------*/
        //GEL_Reset();

        init_emif();

        GEL_TextOut("GEL StartUp Complete.\n");
    }

    /*--------------------------------------------------------------*/
    /* OnReset()                                                    */
    /* This function is called by CCS when you do Debug->Resest.    */
    /* The goal is to put the C6x into a known good state with      */
    /* respect to cache, edma and interrupts.                       */
    /*--------------------------------------------------------------*/
    OnReset( int nErrorCode )
    {
        /*------------------------------------------------------*/
        /* A debugger reset or GEL_Reset() does NOT reset the   */
        /* C6713 pll. Uncomment the following line if you want  */
        /* your pll reset.                                      */
        /*------------------------------------------------------*/
        //reset_pll();

        init_emif();
    }

    /*--------------------------------------------------------------*/
    /* OnPreFileLoaded()                                            */
    /* This function is called automatically when the 'Load Program'*/
    /* Menu item is selected.                                       */
    /*--------------------------------------------------------------*/
    OnPreFileLoaded()
    {
        /*------------------------------------------------------*/
        /* GEL_Reset() is used to deal with the worst case      */
        /* senario of unknown target state.  If for some reason */
        /* a reset is not desired upon target connection,       */
        /* GEL_Reset() may be removed and replaced with         */
        /* something "less brutal" like a cache initialization  */
        /* function.                                            */
        /*------------------------------------------------------*/
        GEL_Reset();

        flush_cache();
        IER = 0;
        IFR = 0;
        init_emif();
    }

    /*--------------------------------------------------------------*/
    /* OnRestart()                                                  */
    /* This function is called by CCS when you do Debug->Restart.   */
    /* The goal is to put the C6x into a known good state with      */
    /* respect to cache, edma and interrupts.                       */
    /* Failure to do this can cause problems when you restart and   */
    /* run your application code multiple times.  This is different */
    /* then OnPreFileLoaded() which will do a GEL_Reset() to get the*/
    /* C6x into a known good state.                                 */
    /*--------------------------------------------------------------*/
    OnRestart(int nErrorCode )
    {
        /*------------------------------------------------------*/
        /* Turn off L2 for all EMIFA CE spaces.  App should     */
        /* manage these for coherancy in the application.       */
        /* GEL_TextOut("Turn off cache segment\n");             */
        /*------------------------------------------------------*/
        *(int *)0x01848200 = 0;             // MAR0
        *(int *)0x01848204 = 0;             // MAR1
        *(int *)0x01848208 = 0;             // MAR2
        *(int *)0x0184820c = 0;             // MAR3

        /*------------------------------------------------------*/
        /* Disable EDMA events and interrupts and clear any     */
        /* pending events.                                      */
        /* GEL_TextOut("Disable EDMA event\n");                 */
        /*------------------------------------------------------*/
        *(int *)0x01A0FFE8 = 0;             // CIERL
        *(int *)0x01A0FFF4 = 0;             // EERL
        *(int *)0x01A0FFF8 = 0xFFFFFFFF;    // ECRL

        /* Disable other interrupts */
        IER = 0;
        IFR = 0;
    }

    /*--------------------------------------------------------------*/
    /* setup_memory_map()                                           */
    /* Memory map setup                                             */
    /*--------------------------------------------------------------*/
    setup_memory_map()
    {
        GEL_MapOn();
        GEL_MapReset();

        /* On-chip memory map */
        GEL_MapAdd(0x00000000, 0, 0x00030000, 1, 1); // Internal RAM (L2) mem
        GEL_MapAdd(0x01800000, 0, 0x00000024, 1, 1); // EMIF control regs
        GEL_MapAdd(0x01840000, 0, 0x00000004, 1, 1); // Cache configuration reg
        GEL_MapAdd(0x01844000, 0, 0x00000018, 1, 1); // L2 base addr & count regs
        GEL_MapAdd(0x01844020, 0, 0x00000018, 1, 1); // L1 base addr & count regs
        GEL_MapAdd(0x01845000, 0, 0x00000008, 1, 1); // L2 flush & clean regs
        GEL_MapAdd(0x01848200, 0, 0x00000010, 1, 1); // CE0 mem attribute regs
        GEL_MapAdd(0x01848240, 0, 0x00000010, 1, 1); // CE1 mem attribute regs
        GEL_MapAdd(0x01848280, 0, 0x00000010, 1, 1); // CE2 mem attribute regs
        GEL_MapAdd(0x018482c0, 0, 0x00000010, 1, 1); // CE3 mem attribute regs
        GEL_MapAdd(0x01880000, 0, 0x00000004, 1, 1); // HPI control reg
        GEL_MapAdd(0x018c0000, 0, 0x00000028, 1, 1); // McBSP0 regs
        GEL_MapAdd(0x01900000, 0, 0x00000028, 1, 1); // McBSP1 regs
        GEL_MapAdd(0x01940000, 0, 0x0000000c, 1, 1); // Timer0 regs
        GEL_MapAdd(0x01980000, 0, 0x0000000c, 1, 1); // Timer1 regs
        GEL_MapAdd(0x019c0000, 0, 0x0000000c, 1, 1); // Interrupt selector regs
        GEL_MapAdd(0x019c0200, 0, 0x00000004, 1, 1); // Device configuration

        GEL_MapAdd(0x01a00000, 0, 0x00000800, 1, 1); // EDMA parameter RAM
        GEL_MapAdd(0x01a0ff00, 0, 0x00000010, 1, 1); // EDMA event selector
        GEL_MapAdd(0x01a0ffe0, 0, 0x00000020, 1, 1); // EDMA control regs

        GEL_MapAdd(0x01b00000, 0, 0x00000028, 1, 1); // GPIO
        GEL_MapAdd(0x01b40000, 0, 0x0000003c, 1, 1); // I2C0
        GEL_MapAdd(0x01b44000, 0, 0x0000003c, 1, 1); // I2C1
        GEL_MapAdd(0x01b4c000, 0, 0x00000300, 1, 1); // McASP0
        GEL_MapAdd(0x01b50000, 0, 0x00000300, 1, 1); // McASP1
        GEL_MapAdd(0x01b7c000, 0, 0x00000128, 1, 1); // PLL

        GEL_MapAdd(0x01bc0000, 0, 0x00000050, 1, 1); // Emulation regs
        GEL_MapAdd(0x02000000, 0, 0x00000014, 0, 1); // QDMA regs
        GEL_MapAdd(0x02000020, 0, 0x00000014, 0, 1); // QDMA pseudo-regs
        GEL_MapAdd(0x30000000, 0, 0x04000000, 1, 1); // McBSP0 data
        GEL_MapAdd(0x34000000, 0, 0x04000000, 1, 1); // McBSP1 data

        GEL_MapAdd(0x3c000000, 0, 0x00010000, 1, 1); // McASP0 data
        GEL_MapAdd(0x3c100000, 0, 0x00010000, 1, 1); // McASP1 data

        /* Off-chip memory map */
        GEL_MapAdd(0x80000000, 0, 0x01000000, 1, 1); // CE0, SDRAM, 16 MBytes
        GEL_MapAdd(0x90000000, 0, 0x00040000, 1, 1); // CE1, 8-bit ROM, 256KBytes
        GEL_MapAdd(0x90080000, 0, 0x00000008, 1, 1); // CE1, 8-bit I/O port
        GEL_MapAdd(0xA0000000, 0, 0x10000000, 1, 1); // CE2 - Daughtercard
        GEL_MapAdd(0xB0000000, 0, 0x10000000, 1, 1); // CE3 - Daughtercard
    }

    /*--------------------------------------------------------------*/
    /* clear_memory_map()                                           */
    /* Memory map disable                                           */
    /*--------------------------------------------------------------*/
    clear_memory_map()
    {
        GEL_MapOff();
    }

    /*--------------------------------------------------------------*/
    /* CPLD DEFINITIONS                                             */
    /*--------------------------------------------------------------*/
    #define CPLD_STAT         0x90080000
    #define CPLD_DC           0x90080001
    #define CPLD_REV          0x90080004
    #define CPLD_MISC         0x90080006

    #define Get_Board_Rev     ((*(char *)CPLD_REV) & 0x07)
    #define Get_Cpld_Rev      ((*(char *)CPLD_REV>>4) & 0x0F)
    #define Get_Switches      ((*(char *)CPLD_STAT>>4) & 0x0F)

    #define LED0_on           *(char *)CPLD_STAT = 0x01
    #define LED1_on           *(char *)CPLD_STAT = 0x02
    #define LED2_on           *(char *)CPLD_STAT = 0x04
    #define LED3_on           *(char *)CPLD_STAT = 0x08
    #define LEDs_off          *(char *)CPLD_STAT = 0x00

    /*--------------------------------------------------------------*/
    /* init_emif()                                                  */
    /* Emif initialization                                          */
    /*--------------------------------------------------------------*/
    init_emif()
    {
        #define EMIF_GCTL       0x01800000
        #define EMIF_CE1        0x01800004
        #define EMIF_CE0        0x01800008
        #define EMIF_CE2        0x01800010
        #define EMIF_CE3        0x01800014
        #define EMIF_SDRAMCTL   0x01800018
        #define EMIF_SDRAMTIM   0x0180001C
        #define EMIF_SDRAMEXT   0x01800020
        #define EMIF_CCFG       0x01840000;     // Cache configuration register

        /* EMIF setup */
        *(int *)EMIF_GCTL     = 0x00000068;
        *(int *)EMIF_CE0      = 0xffffbf33;     // CE0 SDRAM
        *(int *)EMIF_CE1      = 0x02208802;     // CE1 Flash 8-bit
        *(int *)EMIF_CE2      = 0x22a28a22;     // CE2 Daughtercard 32-bit async
        *(int *)EMIF_CE3      = 0x22a28a22;     // CE3 Daughtercard 32-bit async

        if (Get_Board_Rev == 2)
        {
            *(int *)EMIF_SDRAMCTL = 0x57115000; // SDRAM control (16 Mb)
        }
        else
        {
            *(int *)EMIF_SDRAMCTL = 0x47115000; // SDRAM control (8 Mb)
        }
        *(int *)EMIF_SDRAMTIM = 0x00000578;     // SDRAM timing (refresh)
        *(int *)EMIF_SDRAMEXT = 0x000a8529;     // SDRAM Extension register
    }

    /*--------------------------------------------------------------*/
    /* flush_cache()                                                */
    /* Flush L1 & L2 cache                                          */
    /*--------------------------------------------------------------*/
    flush_cache()
    {
        /* Invalidate L1P and L1D */
        *(int *)0x01840000 = (*(int *)0x01840000 | 0x00000300);

        /* Clean L2 */
        *(int *)0x01845004 = 0x1;
    }

    /*--------------------------------------------------------------*/
    /* init_cpld()                                                  */
    /* CPLD Initialization                                          */
    /*--------------------------------------------------------------*/
    init_cpld()
    {
        *(char*)CPLD_STAT = 0;
        *(char*)CPLD_DC   = 0;
        *(char*)CPLD_MISC = 0;
    }

    /*--------------------------------------------------------------*/
    /* C6713 PLL SUPPORT                                            */
    /*--------------------------------------------------------------*/
    #define PLL_BASE_ADDR   0x01b7c000
    #define PLL_PID         ( PLL_BASE_ADDR + 0x000 )
    #define PLL_CSR         ( PLL_BASE_ADDR + 0x100 )
    #define PLL_MULT        ( PLL_BASE_ADDR + 0x110 )
    #define PLL_DIV0        ( PLL_BASE_ADDR + 0x114 )
    #define PLL_DIV1        ( PLL_BASE_ADDR + 0x118 )
    #define PLL_DIV2        ( PLL_BASE_ADDR + 0x11C )
    #define PLL_DIV3        ( PLL_BASE_ADDR + 0x120 )
    #define PLL_OSCDIV1     ( PLL_BASE_ADDR + 0x124 )

    #define CSR_PLLEN          0x00000001
    #define CSR_PLLPWRDN       0x00000002
    #define CSR_PLLRST         0x00000008
    #define CSR_PLLSTABLE      0x00000040
    #define DIV_ENABLE         0x00008000

    /*--------------------------------------------------------------*/
    /* reset_pll()                                                  */
    /* Pll Reset                                                    */
    /*--------------------------------------------------------------*/
    reset_pll()
    {
        /* Set the PLL back to power on reset state*/
        *(int *)PLL_CSR     = 0x00000048;
        *(int *)PLL_DIV3    = 0x00008001;
        *(int *)PLL_DIV2    = 0x00008001;
        *(int *)PLL_DIV1    = 0x00008000;
        *(int *)PLL_DIV0    = 0x00008000;
        *(int *)PLL_MULT    = 0x00000007;
        *(int *)PLL_MULT    = 0x00000007;
        *(int *)PLL_OSCDIV1 = 0x00080007;
    }

    /*--------------------------------------------------------------*/
    /* init_pll()                                                   */
    /* Pll Initialization                                           */
    /*--------------------------------------------------------------*/
    init_pll()
    {
        /*------------------------------------------------------*/
        /* When PLLEN is off DSP is running with CLKIN clock    */
        /* source, currently 50MHz or 20ns clk rate.            */
        /*------------------------------------------------------*/
        *(int *)PLL_CSR  &= ~CSR_PLLEN;

        /* Reset the pll.  PLL takes 125ns to reset. */
        *(int *)PLL_CSR  |= CSR_PLLRST;

        /*------------------------------------------------------*/
        /* PLLOUT = CLKIN/(DIV0+1) * PLLM                       */
        /* 450    = 50/1 * 9                                    */
        /*------------------------------------------------------*/
        *(int *)PLL_DIV0    = DIV_ENABLE + 0;
        *(int *)PLL_MULT    = 9;
        *(int *)PLL_OSCDIV1 = DIV_ENABLE + 4;

        /*------------------------------------------------------*/
        /* Program in reverse order.                            */
        /* DSP requires that pheriheral clocks be less then     */
        /* 1/2 the CPU clock at all times.                      */
        /*------------------------------------------------------*/
        *(int *)PLL_DIV3    = DIV_ENABLE + 4;
        *(int *)PLL_DIV2    = DIV_ENABLE + 3;
        *(int *)PLL_DIV1    = DIV_ENABLE + 1;
        *(int *)PLL_CSR    &= ~CSR_PLLRST;

        /*------------------------------------------------------*/
        /* Now enable pll path and we are off and running at    */
        /* 225MHz with 90 MHz SDRAM.                            */
        /*------------------------------------------------------*/
        *(int *)PLL_CSR |= CSR_PLLEN;
    }

    /*--------------------------------------------------------------*/
    /* DSK6713 MENU                                                 */
    /*--------------------------------------------------------------*/
    menuitem "DSK6713 Functions";

    hotmenu Reset()
    {
        GEL_Reset( );
    }

    hotmenu InitEmif()
    {
        init_emif();
    }

    hotmenu InitPll()
    {
        init_pll();
    }

    hotmenu InitCpld()
    {
        init_cpld();
    }

    /*--------------------------------------------------------------*/
    /* RESET MENU                                                   */
    /*--------------------------------------------------------------*/
    menuitem "Resets";

    hotmenu ClearBreakPts_Reset_EMIFset()
    {
        GEL_BreakPtReset();
        GEL_Reset();
        init_emif();
    }

    hotmenu FlushCache()
    {
        flush_cache();
    }

    hotmenu ResetPll()
    {
        reset_pll();
    }

    /*--------------------------------------------------------------*/
    /* MEMORY MAP MENU                                              */
    /*--------------------------------------------------------------*/
    menuitem "Memory Map";

    hotmenu SetMemoryMap()
    {
        setup_memory_map();
    }

    hotmenu ClearMemoryMap()
    {
        clear_memory_map();
    }

    /*--------------------------------------------------------------*/
    /* LED_cycle()                                                  */
    /*--------------------------------------------------------------*/
    LED_cycle()
    {
        LED3_on;
        LED2_on;
        LED1_on;
        LED2_on;
        LED3_on;
        LEDs_off;
    }

    /*--------------------------------------------------------------*/
    /* Check DSK MENU                                               */
    /*--------------------------------------------------------------*/
    menuitem "Check DSK";
    hotmenu QuickTest()
    {
        LED_cycle();
        LED_cycle();
        LED_cycle();
        GEL_TextOut(" Switches: %d  Board Revision: %d CPLD Revision: %d\n\n",
                     "DSKOutput", 1, 1, 1, Get_Switches, Get_Board_Rev, Get_Cpld_Rev);
    }

    Regards,

    BAS

  • Al Salam,

    Your Flash based runtime need to do what the following does

    OnPreFileLoaded()
    {
        /*------------------------------------------------------*/
        /* GEL_Reset() is used to deal with the worst case      */
        /* senario of unknown target state.  If for some reason */
        /* a reset is not desired upon target connection,       */
        /* GEL_Reset() may be removed and replaced with         */
        /* something "less brutal" like a cache initialization  */
        /* function.                                            */
        /*------------------------------------------------------*/
        GEL_Reset();

        flush_cache();
        IER = 0;
        IFR = 0;
        init_emif();
    }
    Good Luck,

    Sam

  • Along with the PLL init etc...

  • Walaikun As Salam,

    I am sorry but I didn't get what you mean.

    How could I debug what is causing the problem in Flash based routine ?

  • What I meant is your Flash based run time start up need to do the same sequence of initialization done in the Gel.  You have the ability to set HW breakpoints in CCS to step through the code.

  • Sam,

    How can I use HW break point to analyze the gel file ? I know I can do that with main.c but how to see Gel file sequence of initilization ?

  • I am sorry but Gel code can not be debugged, it execute in the background.  You can make a C module containing the same code, dispose then from the use of the Gel at CCS start up, load your version of start up, then you can debug the sequence of start up code.

  • Sam,

    I managed to solve the problem. I initialize the PLL and EMIF with in main() of my code. Now ADC is showing the right sampling frequency.

    I don't know why PLL and EMIF are not being initialized properly by Gel file.

    Is it ok to initilize them the way I did ?

    -Tariq

  • Yes, your stand alone run-time should do that as part of the start-up, and not depend on a Gel in CCS.

    Good Luck,

    Sam

  • Sam,

    I am facing strange kind of problem. I am able to write variable 'FFT_MAGNITUDE' to Flash but when I try to write another variable to Flash, it doesn't write and keep moving in dsk6713_flash_write.c file at the line given below.

     *((volatile Uint8 *)DSK6713_FLASH_CTL555) = 0xaa;

    My program flows in the following way,

    Calculating FFT Magnitude..

    then saving some values to variable mnmx

            mnmx[mm] = fft_mag[10];   
            mm++;
            mnmx[mm] = fft_mag[20];   
            mm++;
            mnmx[mm] = fft_mag[30];   
            mm++;
            mnmx[mm] = fft_mag[40];  
            mm++;

    then calling these function

            minmax ();
            percentile();

    After executing above functions variable mnmx bas 19 values which I am trying to write to Flash in the following way

    DSK6713_FLASH_write((Uint32) mnmx, start1, length1);

    but it doesn't writeto Flash and get stuck at the line mentioned above. After halting when I see Flash memory, I see some garbage values written to Flash.

    But when I write variable FFT_MAGNITUDE, it writes properly with the same command.

    I am scratching my head figuring out what could be wrong.

    I will appreciate your comments in this regards.

    -Tariq



  • Al Salam,

    This line

    *((volatile Uint8 *)DSK6713_FLASH_CTL555) = 0xaa;

    appear to be for writing/programming the device in 16 bits mode on the AM29LV400.

    Can you please share with me your dsk6713_flash_write.c and its associated header files.

    Sam

  • Walaikum As Salam Sam,

    It's for 8 bit word and I am using the same file for writing other variable to Flash.

    Here attached your required files.


     *  ======== dsk6713_flash_write.c ========

    #include <std.h>
    #include <csl.h>

    #include <dsk6713.h>
    #include <dsk6713_flash.h>

    /* Write data to a data range in Flash */
    void DSK6713_FLASH_write(Uint32 src, Uint32 dst, Uint32 length)
    {
        volatile Uint8 *psrc, *pdst;
        Uint32 i;

        /* Establish source and destination */
        psrc = (Uint8 *)src;
        pdst = (Uint8 *)dst;
        for (i = 0; i < length; i++)
        {
            // Program one 8-bit word
            *((volatile Uint8 *)DSK6713_FLASH_CTL555) = 0xaa;
            *((volatile Uint8 *)DSK6713_FLASH_CTL2AA) = 0x55;
            *((volatile Uint8 *)DSK6713_FLASH_CTL555) = 0xa0;
            *pdst = *psrc;

            // Wait for operation to complete
            while(1)
                if (*pdst == *psrc)
                    break;

            pdst++;
            psrc++;
        }

        /* Put back in read mode */
        *((volatile Uint16 *)DSK6713_FLASH_BASE) = 0xf0;
    }

     *  ======== dsk6713_flash.h ========

    #ifndef DSK6713_FLASH_
    #define DSK6713_FLASH_

    #ifdef __cplusplus
    extern "C" {
    #endif

    #include <csl.h>

    /* Flash address definitions */
    #define DSK6713_FLASH_BASE          0x90000000
    #define DSK6713_FLASH_PAGESIZE      0x08000
    #define DSK6713_FLASH_PAGES         0x8
    #define DSK6713_FLASH_SIZE          0x040000
    #define DSK6713_FLASH_CTL555        (DSK6713_FLASH_BASE + (0x555 << 0))
    #define DSK6713_FLASH_CTL2AA        (DSK6713_FLASH_BASE + (0x2aa << 0))
    #define DSK6713_FLASH_CTLAAA        (DSK6713_FLASH_BASE + (0xaaa << 0))
    #define DSK6713_FLASH_SUPPORT       1

    /* Calculate the checksum of a data range in Flash */
    Uint32 DSK6713_FLASH_checksum(Uint32 start, Uint32 length);

    /* Erase a segment of Flash memory */
    void DSK6713_FLASH_erase(Uint32 start, Uint32 length);

    /* Read data from a range in Flash */
    void DSK6713_FLASH_read(Uint32 src, Uint32 dst, Uint32 length);

    /* Write data to a data range in Flash */
    void DSK6713_FLASH_write(Uint32 src, Uint32 dst, Uint32 length);

    #ifdef __cplusplus
    }
    #endif

    #endif

    -Tariq

  • Al Salam,

    From the FLASH DS

    It appear that the code you are using is porgramming it in WORD mode and not BYTE mode.

    Sam

  • I am using the code as it is shipped by spectrum digital. I never encountered any problem so I really didn't know what mode it is writing.

    I don't understand why it is writing FFT MAG and not the other variable ?

    Can you please tell me what should I do now ?

  • Try this modified code set based on the FLASH device table I sent you earlier

     

     *  ======== dsk6713_flash_write.c ========

    #include <std.h>
    #include <csl.h>

    #include <dsk6713.h>
    #include <dsk6713_flash.h>

    /* Write data to a data range in Flash */
    void DSK6713_FLASH_write(Uint32 src, Uint32 dst, Uint32 length)
    {
        volatile Uint8 *psrc, *pdst;
        Uint32 i;

        /* Establish source and destination */
        psrc = (Uint8 *)src;
        pdst = (Uint8 *)dst;
        for (i = 0; i < length; i++)
        {
            // Program one 8-bit word
            *((volatile Uint8 *)DSK6713_FLASH_CTLAAA) = 0xaa;
            *((volatile Uint8 *)DSK6713_FLASH_CTL555) = 0x55;
            *((volatile Uint8 *)DSK6713_FLASH_CTLAAA) = 0xa0;
            *pdst = *psrc;
            /* put some delay here */
            // Wait for operation to complete
            while(1)

            {

            /* put some delay here */
                if (*pdst == *psrc)
                    break;
            }
            pdst++;
            psrc++;
        }

        /* Put back in read mode */
        *((volatile Uint16 *)DSK6713_FLASH_BASE) = 0xf0;
    }

    *  ======== dsk6713_flash.h ========

    #ifndef DSK6713_FLASH_
    #define DSK6713_FLASH_

    #ifdef __cplusplus
    extern "C" {
    #endif

    #include <csl.h>

    /* Flash address definitions */
    #define DSK6713_FLASH_BASE          0x90000000
    #define DSK6713_FLASH_PAGESIZE      0x08000
    #define DSK6713_FLASH_PAGES         0x8
    #define DSK6713_FLASH_SIZE          0x040000
    #define DSK6713_FLASH_CTL555        (DSK6713_FLASH_BASE + (0x555 << 0))
    #define DSK6713_FLASH_CTL2AA        (DSK6713_FLASH_BASE + (0x2aa << 0))
    #define DSK6713_FLASH_CTLAAA        (DSK6713_FLASH_BASE + (0xaaa << 0))
    #define DSK6713_FLASH_SUPPORT       1

    /* Calculate the checksum of a data range in Flash */
    Uint32 DSK6713_FLASH_checksum(Uint32 start, Uint32 length);

    /* Erase a segment of Flash memory */
    void DSK6713_FLASH_erase(Uint32 start, Uint32 length);

    /* Read data from a range in Flash */
    void DSK6713_FLASH_read(Uint32 src, Uint32 dst, Uint32 length);

    /* Write data to a data range in Flash */
    void DSK6713_FLASH_write(Uint32 src, Uint32 dst, Uint32 length);

    #ifdef __cplusplus
    }
    #endif

    #endif

  • Assalam Allaikum,

    I tried with the modified code, now it doesn't write even the fft magnitude variable to Flash.

    I generated few variables and successfully wrote them to Flash with previous flash_write.c code. I realized that the problem raises when fft magnitude buffer get involves with any other variable.

    When I save few fft magnitude values to any variable even except mnmx variable, it doesn't write to Flash. It stuck at the same position which I explained before and the length doesn't decrease with each iteration.

    I don't see any problem the way I initialized mnmx and the way it is saving values from fft_mag but doesn't work..

    float mnmx[19];

            mnmx[mm] = fft_mag[10];  
            mm++;
            mnmx[mm] = fft_mag[20];   
            mm++;
            mnmx[mm] = fft_mag[30];
            mm++;
            mnmx[mm] = fft_mag[40]; 
            mm++;

  • Al Salam,

    1. Make certain EMIF programming is correct to access the FLASH during run-time.  At reset is has a very slow speed due to reset default values and that permit code fetch.

    2. Make certain all erase/write functions etc... of FLASH ends with the proper reset command

        /* Put back in read mode */
        *((volatile Uint8 *)DSK6713_FLASH_BASE) = 0xf0;

    3. Write a walking one (or the lower 8 bits of the address) in a test routine across the FLASH space to verify that you can write to all cells and read back.

    Good Luck,

    Sam

  • 4263.Flash_Tariq.zip

    Walaikum as Salam,

    I checked Flash erase, write and read. They all are working fine. I am able to erase, write and read. But again the same problem raised when writing with mnmx variable.

    I erased the flash with Flash Burn software and flashed post.hex to make the flash back to the way it came with the DSK. After that I compiled my program, it wrote mnmx to Flash only once (I don't know how) but after that same problem appeared and stopped writing to Flash.

    I am unable to understand what's wrong.

    I will appreciate your couple of minutes to go through my code if you have some time.

    Thanks a lot for your help.

    Regards.

  • Al Salam,

    A Q before I go in.  I assume you are running this only out of CCS with the Gel doing your init?

    Sam

  • BTW, give your e-mail address to take this offline.

  • To boot and run from FLASH without a CCS/EMU, you will need to have a 2nd boot loader to copy your run time.  Please read

  • Sam,

    Sorry, I was out of town so couldn't reply.

    My email address: basahm.siddiqui@gmail.com

    I am not booting from Flash with the code I gave you because of the problem while writing 'mnmx' variable. I am using 2nd boot loader to copy the code.

    But for other code running out of CCS, Gel is doing init but I am also initializing PLL and EMIF with in my code (as discussed before).

    I really appreciate your help.

  • Your e-mail is bouncing back.  There must be an error in it.

  • Greetings,

    I am glad I can help.  This issue is resolved.

    Good Luck,

    Sam