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.

TMS320F28035: EEPROM emulation with Flash not working reliably

Part Number: TMS320F28035

In my project based on TMS320F28035 I am trying to emulate eeprom in on chip flash.   I followed the application note - Application Report
EEPROM Emulation for Gen 2 C2000 Real-Time MCUs (SPRab69a1).  I modified the following  files to integrate with my code

DSP280x_MemCopy.c
F280xx_EEPROM.c
F280xx_EEPROM.h

F28035.cmd

I am using Sector H (  FLASHH      : origin = 0x3E8000, length = 0x002000 )

While running the code the eeprom write works for 1st 3 to 6 times and then fails with status code as 30 or 31 and code also crashes and controller resets.

Attaching the files.  Appreciate if you could help me in finding why it is crashing. 

Regards,

Ramesh

0636.F280xx_EEPROM.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//############################################################################
//
// FILE: F280xx_EEPROM.c
//
// TITLE: EEPROM Read, Write, and Erase Functions
//
//############################################################################
// Authors: Tim Love / Pradeep Shinde
// Release Date: Sep 2009
//############################################################################
#include "F280xx_EEPROM.h" // EEPROM Include File
// Global Variables
Uint16 Read_Buffer[64];
Uint16 Write_Buffer[64];
Uint16 Bank_Counter = 0;
Uint16 Page_Counter = 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
4341.F280xx_EEPROM.h
DSP280x_MemCopy.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// TI File $Revision: /main/1 $
// Checkin $Date: December 1, 2004 11:12:01 $
//###########################################################################
//
// FILE: DSP280x_MemCopy.c
//
// TITLE: Memory Copy Utility
//
// ASSUMPTIONS:
//
//
//
// DESCRIPTION:
//
// This function will copy the specified memory contents from
// one location to another.
//
// Uint16 *SourceAddr Pointer to the first word to be moved
// SourceAddr < SourceEndAddr
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
*
// TI File $Revision: /main/4 $
// Checkin $Date: November 9, 2009 15:09:12 $
//###########################################################################
//
// FILE: F2808.cmd
//
// TITLE: Linker Command File For F2808 Device
//
//###########################################################################
// $TI Release: F2803x Support Library v2.01.00.00 $
// $Release Date: Sun Sep 29 07:32:51 CDT 2019 $
// $Copyright:
// Copyright (C) 2009-2019 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hello Ramesh,

    I assume that by status codes 30 and 31 you're referring to the return status for the Flash API:

    When you ran your program, did you verify that the Flash was erased? At what line in your above code are you getting the error status?

    While running the code the eeprom write works for 1st 3 to 6 times and then fails with status code as 30 or 31 and code also crashes and controller resets.

    Are the status code and crash/reset independent issues, or when there's an error status the code crashes and resets? How are you detecting if the device resets?

    Best regards,

    Omer Amir

  • Hi Omer Amir,

    Thanks for the quick response.  

    "I assume that by status codes 30 and 31 you're referring to the return status for the Flash API:"

    Yes.  I am referring to the return status of Flash APi.

    Actually I assumed all the flash memory is erased every time I  do 'run' from CCS( Not sure if I am correct).  I did not erase that sector explicitly.

    The crash and error status coincide.  Whenever flash api returns error status, the code crashes and resets.  I have enabled watchdog in the code.  However as per api documentation the watchdog is disabled when the api is called.  After reset I can also see the WDFLAG is set in WDCR register.

    Regards,

    Ramesh

  • I browsed the flash memory at the location and all shows 0xFFFF.

    During successful writes  I can see the memory as below

    0x003E8042
    00FF 0000 0000 0000
    0000 0000 0000 8A08 FFFF
    0020 493E 0003 FFFF 8A0B
    0034 0100 001F FFFF FFFF
    FFFF FFFF FFFF FFFF FFFF
    FFFF FFFF FFFF FFFF

    After failures Every page is filled with following data( not only the page I am writing).

    0000 0000 0000 0000
    0000 0000 0000 8A08 FFFF
    0020 493E 0003 FFFF 8A0B
    0034 0100 001F FFFF FFFF
    FFFF FFFF FFFF FFFF FFFF
    FFFF FFFF FFFF FFFF

    Attaching the screenshot of watch window to track Bank pointer and page pointer

  • Hello Ramesh,

    If you step through your code, are you able to find out at what point that Flash memory is being erased/programmed? Flash erasures happen at a sector level, so it looks like the program happened not as expected after it was erased. If my understanding is incorrect, let me know.

    Best regards,

    Omer Amir

  • Hi Omer Amir,

    The flash memory is erased during the downloading of code in CCS.  After that it is not erased.  As per the code erase will happen after 3 banks are used and we have not reached that level.  The problem happens after 1st bank 3rd page or 2nd bank 2nd page.  If I comment  EEPROM_Write(); the code does not crash.  So my assumption is some issue with  EEPROM_Write(); 

    Regards,

    Ramesh 

  • Hello Ramesh,

    You mentioned in your initial post that you followed an application report and then made some modifications based on your program; did you confirm that the project worked fine when just following that document? Can you one-by-one test individual changes you made (if this applies)?

    If I comment  EEPROM_Write(); the code does not crash.  So my assumption is some issue with  EEPROM_Write(); 

    Can you further narrow down the issue by stepping into the function and running line-by-line? Ideally we should find the instruction or set of instructions which are causing the issue, and then narrow down the issue in memory.

    Best regards,

    Omer Amir

  • Hi Omer Amir,

    Sorry,  I was on vacation.  I solved the problem by Disabling the interrupts before calling      EEPROM_Write(); function.  It works fine.

    Regards,

    Ramesh