Update repo

This commit is contained in:
2026-08-30 23:04:35 -07:00
parent 749dab5721
commit ce65a0f59a
14950 changed files with 4408250 additions and 1 deletions
@@ -0,0 +1,35 @@
<projectSpec>
<project
name="flash_ex2_ecc_test_mode"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${FlashAPI_INCLUDE_ROOT} -v28 -ml -mt --define=DEBUG --define=CPU1 --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="-I${FlashAPI_LIB_ROOT} --entry_point code_start --stack_size=0x3F8 --heap_size=0x200" />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<pathVariable name="FlashAPI_INCLUDE_ROOT" path="../../../../../../libraries/flash_api/f2838x/c28x/include/FlashAPI/" scope="project" />
<pathVariable name="FlashAPI_LIB_ROOT" path="../../../../../../libraries/flash_api/f2838x/c28x/lib/" scope="project" />
<file action="copy" path="../../../../../../libraries/flash_api/f2838x/c28x/lib/F2838x_C28x_FlashAPI.lib" targetDirectory="" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../flash_ex2_ecc_test_mode.c" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,38 @@
<projectSpec>
<project
name="flash_ex3_flash_to_ram"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_RAM" compilerBuildOptions= "--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define=RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=RAM -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${C2000WARE_ROOT} -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --gen_func_subsections=on --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200 --define=_FLASH -i${C2000WARE_ROOT} -i${PROJECT_BUILD_DIR}/syscfg -lc2000ware_libraries.cmd.genlibs " />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<pathVariable name="CLB_SYSCFG_ROOT" path="../../../../../../utilities/clb_tool/clb_syscfg/" scope="project" />
<pathVariable name="SYSTEMC_INSTALL" path="../../../../../../utilities/clb_tool/clb_syscfg/systemc-2.3.3" scope="project" />
<pathVariable name="CLB_SIM_COMPILER" path="C:/TDM-GCC-64/bin" scope="project" />
<buildVariable name="GENERATE_DIAGRAM" value="0" scope="project" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../flash_ex3_flash_to_ram.c" targetDirectory="" />
<file action="copy" path="../flash_ex3_flash_to_ram.syscfg" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,36 @@
<projectSpec>
<project
name="flashapi_ex1_programming"
device="TMS320F28388D"
cgtVersion="22.6.1.LTS"
products="sysconfig;C2000WARE"
outputFormat="ELF"
launchWizard="False"
linkerCommandFile=""
enableSysConfigTool="true"
sysConfigBuildOptions="--product ${C2000WARE_ROOT}/.metadata/sdk.json --device F2838x --package 337bga --part F2838x_337bga"
postBuildStep="
echo &quot;========= Build of the CLB simulation has moved to the CLB Tool. Click the '?' icon by the _Generate CLB Simulation File_ enable for more details (located in the Global Parameters of the Tile Design SysConfig module) =============&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/dot_file_libraries/clbDotUtility.js&quot; &quot;${C2000WARE_ROOT}/utilities/clb_tool/clb_syscfg/&quot; &quot;${BuildDirectory}/syscfg&quot; &quot;${BuildDirectory}/syscfg/clb.dot&quot;
;if ${GENERATE_DIAGRAM} == 1 mkdir &quot;${BuildDirectory}/diagrams&quot;
;if ${GENERATE_DIAGRAM} == 1 ${NODE_TOOL} &quot;${C2000WARE_ROOT}/driverlib/.meta/generate_diagrams.js&quot; &quot;${C2000WARE_ROOT}&quot; &quot;${BuildDirectory}/diagrams&quot; &quot;${BuildDirectory}/syscfg&quot;
"
>
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -I${FlashAPI_INCLUDE_ROOT} -v28 -ml -mt --define=DEBUG --define=_FLASH --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="-I${FlashAPI_LIB_ROOT} --entry_point code_start --stack_size=0x3F8 --heap_size=0x200" />
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
<pathVariable name="C2000WARE_ROOT" path="../../../../../../" scope="project" />
<pathVariable name="FlashAPI_INCLUDE_ROOT" path="../../../../../../libraries/flash_api/f2838x/c28x/include/FlashAPI/" scope="project" />
<pathVariable name="FlashAPI_LIB_ROOT" path="../../../../../../libraries/flash_api/f2838x/c28x/lib/" scope="project" />
<file action="copy" path="../../../../../../libraries/flash_api/f2838x/c28x/lib/F2838x_C28x_FlashAPI.lib" targetDirectory="" />
<file action="copy" path="../flash_programming_f2838x_c28x.h" targetDirectory="" />"""
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_flash_api_lnk.cmd" targetDirectory="" />
<file action="copy" path="../flashapi_ex1_programming.c" targetDirectory="" />
</project>
</projectSpec>
@@ -0,0 +1,357 @@
//#############################################################################
//
// FILE: flash_ex2_ecc_test_mode.c
//
// TITLE: Flash ECC Test Mode Example
//
//! \addtogroup driver_example_list
//! <h1> Flash ECC Test Mode </h1>
//!
//! This example demonstrates ECC Test mode.
//| ECC Test mode is provided to check the correctness of SECDED logic.
//! Four types of errors are inserted to demonstrate the usage of ECC Test Mode
//! 1. Single bit error detection
//! 2. Double bit error detection
//! 3. Single bit ECC error detection
//! 4. Double bit ECC error detection
//!
//! \b External \b Connections \n
//! - None
//!
//! \b Watch \b Variables \n
//! - None
//!
//
//#############################################################################
//
// C2000Ware v5.04.00.00
//
// Copyright (C) 2024 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.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Include Flash API include file
//
#include "F021_F2838x_C28x.h"
uint32 flash_address = 0x84000;
uint64 flash_data = 0xAAAABBBBCCCCDDDD;
uint16 flash_ecc = 0;
uint16 error = 0;
#define DATA_BIT_ERROR_POSITION 7
#define ECC_BIT_ERROR_POSITION 5
//
// Inserts a single bit error in the data before providing the data to ECC Test
// Block
//
void singleBitDataErrorExample();
//
// Inserts a double bit error in the data before providing the data to ECC Test
// Block
//
void doubleBitDataErrorExample();
//
// Inserts a single bit error in the ECC of the data before providing the ecc to
// ECC Test Block
//
void singleBitECCErrorExample();
//
// Inserts a double bit error in the ECC of the data before providing the ecc to
// ECC Test Block
//
void doubleBitECCErrorExample();
//
// Sets ECC Test Block parameters
// Enables the ECC Test mode, uses Lower ECC Test block and performs ECC
// calculation
//
void setupECCTestBlock(uint64 data, uint32 address, uint16 ecc);
#define SINGLE_BIT_DATA_ERROR_EXAMPLE 0
#define DOUBLE_BIT_DATA_ERROR_EXAMPLE 1
#define SINGLE_BIT_ECC_ERROR_EXAMPLE 2
#define DOUBLE_BIT_ECC_ERROR_EXAMPLE 3
//
// Modify the below value to run a different example
//
uint16 current_example = SINGLE_BIT_DATA_ERROR_EXAMPLE;
//
// Main
//
void main(void)
{
//
// Initializes device clock and peripherals
//
Device_init();
//
// Initializes PIE and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// Initialize the Flash API by providing the Flash register base address
// and operating frequency.
//
Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 200);
//
// Get the corresponding ECC of the data
//
flash_ecc = Fapi_calculateEcc(flash_address, flash_data);
switch(current_example) {
case SINGLE_BIT_DATA_ERROR_EXAMPLE:
{
//#####################################################################
// Single bit data error insertion
//#####################################################################
singleBitDataErrorExample();
//
// Get the error type
//
if(FLASH_SINGLE_ERROR != Flash_getECCTestStatus(FLASH0ECC_BASE))
error++;
//
// Check if the detected error is data error
//
if(FLASH_DATA_BITS != Flash_getECCTestSingleBitErrorType(
FLASH0ECC_BASE))
error++;
//
// Check if the detected error position matches with the error position
// set
//
if(DATA_BIT_ERROR_POSITION != Flash_getECCTestErrorPosition(
FLASH0ECC_BASE))
error++;
//
// Check if the SECDED logic corrected single bit error
//
if((uint32)flash_data != Flash_getTestDataOutLow(FLASH0ECC_BASE))
error++;
}
break;
case DOUBLE_BIT_DATA_ERROR_EXAMPLE:
{
//#####################################################################
// Double bit data error insertion
//#####################################################################
doubleBitDataErrorExample();
//
// Get the error type
//
if(FLASH_UNC_ERROR != Flash_getECCTestStatus(FLASH0ECC_BASE))
error++;
}
break;
case SINGLE_BIT_ECC_ERROR_EXAMPLE:
{
//#####################################################################
// Single bit ECC error insertion
//#####################################################################
singleBitECCErrorExample();
//
// Get the error type
//
if(FLASH_SINGLE_ERROR != Flash_getECCTestStatus(FLASH0ECC_BASE))
error++;
//
// Check if the detected error is ecc error
//
if(FLASH_CHECK_BITS != Flash_getECCTestSingleBitErrorType(
FLASH0ECC_BASE))
error++;
//
// Check if the detected error position matches with the error position
// set
//
if(ECC_BIT_ERROR_POSITION != Flash_getECCTestErrorPosition(
FLASH0ECC_BASE))
error++;
}
break;
case DOUBLE_BIT_ECC_ERROR_EXAMPLE:
{
//#####################################################################
// Double bit ECC error insertion
//#####################################################################
doubleBitECCErrorExample();
//
// Get the error type
//
if(FLASH_UNC_ERROR != Flash_getECCTestStatus(FLASH0ECC_BASE))
error++;
}
break;
default:
{
error++;
}
}
//
// Revert back the ECC Test mode setting
//
Flash_disableECCTestMode(FLASH0ECC_BASE);
}
void singleBitDataErrorExample()
{
//
// Insert single bit error in data
//
setupECCTestBlock(flash_data ^ (1 << DATA_BIT_ERROR_POSITION),
flash_address, flash_ecc);
}
void doubleBitDataErrorExample()
{
//
// Insert double bit error in data
//
setupECCTestBlock(flash_data ^ 0x3, flash_address, flash_ecc);
}
void singleBitECCErrorExample()
{
//
// Insert single bit error in ECC
//
setupECCTestBlock(flash_data, flash_address,
flash_ecc ^ (1 << ECC_BIT_ERROR_POSITION));
}
void doubleBitECCErrorExample()
{
//
// Insert double bit error in ECC
//
setupECCTestBlock(flash_data, flash_address, flash_ecc ^ 0x3);
}
void setupECCTestBlock(uint64 data, uint32 address, uint16 ecc)
{
//
// Write 128-bit flash address in FADDR_TEST
//
Flash_setECCTestAddress(FLASH0ECC_BASE, address);
//
// Write lower 32 bits of data in FDATAL_TEST
//
Flash_setDataLowECCTest(FLASH0ECC_BASE, (uint32)data);
//
// Write upper 32 bits of data in FDATAH_TEST
//
Flash_setDataHighECCTest(FLASH0ECC_BASE, (uint32)(data >> 32));
//
// Write corresponding ECC in the FECC_TEST
// Insert double bit error in flash ecc
//
Flash_setECCTestECCBits(FLASH0ECC_BASE, ecc);
//
// Select lower ECC block
// Only one of the SECDED modules (out of the two SECDED modules that work
// on lower 64 bits and upper 64 bits of a read 128-bit data) at a time
// can be tested.
//
Flash_selectLowECCBlock(FLASH0ECC_BASE);
//
// Enable the ECC Test Mode
//
Flash_enableECCTestMode(FLASH0ECC_BASE);
//
// Perform ECC calculation
//
Flash_performECCCalculation(FLASH0ECC_BASE);
}
//
// End of File
//
@@ -0,0 +1,182 @@
//#############################################################################
//
// FILE: flash_to_ram.c
//
// TITLE: Flash to RAM Project
//
// Flash to RAM Project Example
//
// This example is a Flash to RAM example that demonstrates how to start a
// program in Flash and then run certain functions from RAM. The CPU timer
// peripheral is used to monitor the duration of the function in RAM and the
// function in Flash.
//
//#############################################################################
//
//
// $Copyright:
// Copyright (C) 2022 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.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
#include "board.h"
#include "c2000ware_libraries.h"
//
// This pre-processor command loads the function into the .TI.ramfunc
// section of memory
//
// Note: To prevent inconsistent timings when using interrupts, all
// functions where an interrupt can occur should be run from
// RAM. Jumping from a function in Flash to a function in RAM
// may produce inconsistent results
//
#pragma CODE_SECTION(ramCounter, ".TI.ramfunc");
//
// Functions
//
void ramCounter(void);
void flashCounter(void);
//
// Global Variables
//
int i = 0;
volatile uint16_t counter0 = 0;
volatile uint16_t counter1 = 0;
uint16_t ramTime = 0;
uint16_t flashTime = 0;
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
//
Device_init();
//
// Disable pin locks and enable internal pull-ups.
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// PinMux and Peripheral Initialization
//
Board_init();
//
// C2000Ware Library initialization
//
C2000Ware_libraries_init();
//
// Copy functions from .TI.ramfunc from Flash to RAM; the method of using
// binit replaces memcpy in this example, the line remains as a template
// of how the function can be called
//
//EALLOW;
//memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
//EALLOW;
//
// Enable Global Interrupt (INTM) and real time interrupt (DBGM)
//
EINT;
ERTM;
while(1)
{
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
CPUTimer_startTimer(CPUTIMER0_BASE);
ramCounter();
CPUTimer_stopTimer(CPUTIMER0_BASE);
ramTime = CPUTimer_getTimerCount(CPUTIMER0_BASE);
CPUTimer_reloadTimerCounter(CPUTIMER0_BASE);
CPUTimer_startTimer(CPUTIMER0_BASE);
flashCounter();
CPUTimer_stopTimer(CPUTIMER0_BASE);
flashTime = CPUTimer_getTimerCount(CPUTIMER0_BASE);
}
}
//
// This timer function will be running from RAM
//
void ramCounter(void)
{
for(i = 0; i < 10000; i++)
{
counter0++;
}
counter0 = 0;
return;
}
//
// This timer function will be running from Flash;
// the function should run significantly slower than
// the RAM counter function
//
void flashCounter(void)
{
for(i = 0; i < 10000; i++)
{
counter1++;
}
counter1 = 0;
return;
}
//
// End of File
//
@@ -0,0 +1,42 @@
/**
* Import the modules used in this configuration.
*/
const cputimer = scripting.addModule("/driverlib/cputimer.js", {}, false);
const cputimer1 = cputimer.addInstance();
const memcfg = scripting.addModule("/driverlib/memcfg.js");
const CMD = scripting.addModule("/utilities/cmd_tool/cmd_syscfg/source/CMD");
const CMD1 = CMD.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
cputimer1.$name = "myCPUTIMER0";
cputimer1.timerPeriod = 4294967295;
memcfg.init_MEMCFG_SECT_GS1 = true;
scripting.suppress("Error checking and code generation are limited for single core SysConfig on a multicore device\\. Add memcfg module on CPU2 for full functionality\\.", memcfg, "init_MEMCFG_SECT_M0");
CMD.activateCMD = true;
CMD1.$name = "CMD0";
CMD1.sectionMemory_text = ["FLASH1","FLASH2","FLASH3","FLASH4"];
CMD1.sectionAlignEnable_text = true;
CMD1.sectionMemory_cinit = ["FLASH1"];
CMD1.sectionMemory_switch = ["FLASH1"];
CMD1.sectionAlignEnable_bss = true;
CMD1.sectionMemory_bss = ["RAMLS5"];
CMD1.sectionAlignEnable_const = true;
CMD1.sectionMemory_const = ["FLASH5","FLASH6","FLASH7"];
CMD1.sectionMemory_sysmem = ["RAMLS5"];
CMD1.sectionMemory_binit = ["FLASH3"];
CMD1.sectionMemory_ramfunc = ["FLASH3"];
CMD1.sectionMemory_stack = ["RAMM1"];
CMD1.sectionMemory_data = ["RAMLS5"];
CMD1.sectionAlignEnable_cinit = true;
CMD1.sectionAlignEnable_binit = true;
CMD1.sectionAlignEnable_ramfunc = true;
CMD1.sectionAlignEnable_switch = true;
CMD1.sectionMemory_init_array = ["RAMGS1"];
CMD1.sectionRunFromDifferentAddr_ramfunc = true;
CMD1.sectionRun_ramfunc = ["RAMLS0","RAMLS1"];
@@ -0,0 +1,74 @@
//###########################################################################
//
// FILE: flash_programming_f2838x_c28x.h
//
// TITLE: A set of Constant Values for the F2838x C28x Family.
//
//#############################################################################
//
//
//
// C2000Ware v5.04.00.00
//
// Copyright (C) 2024 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.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
#ifndef FLASH_PROGRAMMING_F2838X_C28X_H
#define FLASH_PROGRAMMING_F2838X_C28X_H
//
// Bank0 Sector start addresses
//
#define FlashStartAddress 0x80000
#define Bzero_Sector0_start 0x80000
#define Bzero_Sector1_start 0x82000
#define Bzero_Sector2_start 0x84000
#define Bzero_Sector3_start 0x86000
#define Bzero_Sector4_start 0x88000
#define Bzero_Sector5_start 0x90000
#define Bzero_Sector6_start 0x98000
#define Bzero_Sector7_start 0xA0000
#define Bzero_Sector8_start 0xA8000
#define Bzero_Sector9_start 0xB0000
#define Bzero_Sector10_start 0xB8000
#define Bzero_Sector11_start 0xBA000
#define Bzero_Sector12_start 0xBC000
#define Bzero_Sector13_start 0xBE000
#define FlashEndAddress 0xBFFFF
//
// Sector length in number of 32bits
//
#define Sector16KB_u32length 0x1000
#define Sector64KB_u32length 0x4000
#endif /* FLASH_PROGRAMMING_F2838X_C28X_H */
@@ -0,0 +1,756 @@
//#############################################################################
//
// FILE: flashapi_ex1_programming.c
//
// TITLE: Flash programming example
//
//! \addtogroup driver_example_list
//! <h1> Flash Programming with AutoECC, DataAndECC, DataOnly and EccOnly </h1>
//!
//! This example demonstrates how to program Flash using API's following options
//! 1. AutoEcc generation
//! 2. DataOnly and EccOnly
//! 3. DataAndECC
//!
//!
//! \b External \b Connections \n
//! - None.
//!
//! \b Watch \b Variables \n
//! - None.
//!
//
//#############################################################################
//
// C2000Ware v5.04.00.00
//
// Copyright (C) 2024 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.
//
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the
// distribution.
//
// Neither the name of Texas Instruments Incorporated nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################
//
// Included Files
//
#include "driverlib.h"
#include "device.h"
//
// Include Flash API include file
//
#include "F021_F2838x_C28x.h"
// Include Flash API example header file
//
#include "flash_programming_f2838x_c28x.h"
//
// Defines
//
//
// Length (in 16-bit words) of data buffer used for program
//
#define WORDS_IN_FLASH_BUFFER 0x100
//
// Globals
//
//
// Data Buffers used for program operation using the flash API program function
//
#pragma DATA_SECTION(Buffer,"DataBufferSection");
uint16 Buffer[WORDS_IN_FLASH_BUFFER];
uint32 *Buffer32 = (uint32 *)Buffer;
//
// Prototype of the functions used in this example
//
void Example_Error(Fapi_StatusType status);
void Example_Done(void);
void Example_CallFlashAPI(void);
void FMSTAT_Fail(void);
void ECC_Fail(void);
void Example_EraseSector(void);
void Example_ProgramUsingAutoECC(void);
void Example_ProgramUsingDataOnlyECCOnly(void);
void Example_ProgramUsingDataAndECC(void);
//
// Main
//
void main(void)
{
//
// Initialize device clock and peripherals
// Copy the Flash initialization code from Flash to RAM
// Copy the Flash API from Flash to RAM
// Configure Flash wait-states, fall back power mode, performance features
// and ECC
//
Device_init();
//
// Initialize GPIO
//
Device_initGPIO();
//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
//
// At 200MHz, execution wait-states for external oscillator is 3. Modify the
// wait-states when the system clock frequency is changed.
//
Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, 3);
//
// Pump access must be gained by the core using pump semaphore
//
#ifdef CPU1
Flash_claimPumpSemaphore(FLASH_CPU1_WRAPPER);
#elif defined(CPU2)
Flash_claimPumpSemaphore(FLASH_CPU2_WRAPPER);
#endif
//
// Flash API functions should not be executed from the same bank on which
// erase/program operations are in progress.
// Also, note that there should not be any access to the Flash bank on
// which erase/program operations are in progress. Hence below function
// is mapped to RAM for execution.
//
Example_CallFlashAPI();
//
// Release the pump access
//
Flash_releasePumpSemaphore();
//
// Example is done here
//
Example_Done();
}
//*****************************************************************************
// Example_CallFlashAPI
//
// This function will interface to the flash API.
// Flash API functions used in this function are executed from RAM in this
// example.
//*****************************************************************************
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#else
#pragma CODE_SECTION(Example_CallFlashAPI, ".TI.ramfunc");
#endif
void Example_CallFlashAPI(void)
{
uint16 i = 0;
Fapi_StatusType oReturnCheck;
//
// Initialize the Flash API by providing the Flash register base address
// and operating frequency(in MHz).
// This function is required to initialize the Flash API based on System
// frequency before any other Flash API operation can be performed.
// This function must also be called whenever System frequency or RWAIT is
// changed.
//
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS,
DEVICE_SYSCLK_FREQ/1000000U);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Initialize the Flash banks and FMC for erase and program operations.
// Fapi_setActiveFlashBank() function sets the Flash banks and FMC for
// further Flash operations to be performed on the banks.
//
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Fill a buffer with data to program into the flash.
//
for(i=0; i < WORDS_IN_FLASH_BUFFER; i++)
{
Buffer[i] = i;
}
//
// Program the sector using AutoECC option
//
Example_ProgramUsingAutoECC();
//
// Program the sector using DataOnly and ECCOnly options
//
Example_ProgramUsingDataOnlyECCOnly();
//
// Erase the sector before programming
//
Example_EraseSector();
//
// Program the sector using DataAndECC option
//
Example_ProgramUsingDataAndECC();
//
// Erase the sector for cleaner exit from the example.
//
Example_EraseSector();
}
//*****************************************************************************
// Example_ProgramUsingAutoECC
//
// Example function to Program data in Flash using "AutoEccGeneration" option.
// Flash API functions used in this function are executed from RAM in this
// example.
//*****************************************************************************
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#else
#pragma CODE_SECTION(Example_ProgramUsingAutoECC, ".TI.ramfunc");
#endif
void Example_ProgramUsingAutoECC(void)
{
uint32 u32Index = 0;
uint16 i = 0;
Fapi_StatusType oReturnCheck;
Fapi_FlashStatusType oFlashStatus;
Fapi_FlashStatusWordType oFlashStatusWord;
//
// A data buffer of max 8 16-bit words can be supplied to the program
// function.
// Each word is programmed until the whole buffer is programmed or a
// problem is found. However to program a buffer that has more than 8
// words, program function can be called in a loop to program 8 words for
// each loop iteration until the whole buffer is programmed.
//
// Remember that the main array flash programming must be aligned to
// 64-bit address boundaries and each 64 bit word may only be programmed
// once per write/erase cycle. Meaning the length of the data buffer
// (3rd parameter for Fapi_issueProgrammingCommand() function) passed
// to the program function can only be either 4 or 8.
//
// Program data in Flash using "AutoEccGeneration" option.
// When AutoEccGeneration option is used, Flash API calculates ECC for the
// given 64-bit data and programs it along with the 64-bit main array data.
// Note that any unprovided data with in a 64-bit data slice
// will be assumed as 1s for calculating ECC and will be programmed.
//
// Note that data buffer (Buffer) is aligned on 64-bit boundary for verify
// reasons.
//
// Monitor ECC address for the sector below while programming with
// AutoEcc mode.
//
// In this example, the number of bytes specified in the flash buffer
// are programmed in the flash sector below along with auto-generated
// ECC.
//
for(i=0, u32Index = Bzero_Sector6_start;
(u32Index < (Bzero_Sector6_start + WORDS_IN_FLASH_BUFFER));
i+= 8, u32Index+= 8)
{
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,Buffer+i,
8, 0, 0, Fapi_AutoEccGeneration);
//
// Wait until the Flash program operation is over
//
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Read FMSTAT register contents to know the status of FSM after
// program command to see if there are any program operation related
// errors
//
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
//
//Check FMSTAT and debug accordingly
//
FMSTAT_Fail();
}
//
// Verify the programmed values. Check for any ECC errors.
//
oReturnCheck = Fapi_doVerify((uint32 *)u32Index,
4, Buffer32+(i/2),
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
}
}
//*****************************************************************************
// Example_ProgramUsingDataOnlyECCOnly
//
// Example function to Program data in Flash using "DataOnly" option and ECC
// using "EccOnly" option.
// Flash API functions used in this function are executed from RAM in this
// example.
//*****************************************************************************
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#else
#pragma CODE_SECTION(Example_ProgramUsingDataOnlyECCOnly, ".TI.ramfunc");
#endif
void Example_ProgramUsingDataOnlyECCOnly(void)
{
uint32 u32Index = 0;
uint16 i = 0, ECC_B = 0, ECC_LB = 0, ECC_HB = 0;
uint64 *LData, *HData, dataLow, dataHigh;
Fapi_StatusType oReturnCheck;
Fapi_FlashStatusType oFlashStatus;
Fapi_FlashStatusWordType oFlashStatusWord;
//
// Program data using "DataOnly" option and ECC using "EccOnly" option.
//
// When DataOnly option is used, Flash API will program only the data
// portion in Flash at the address specified.
//
// When EccOnly option is used, Flash API will program only the ECC portion
// in Flash ECC memory space (Flash main array address should be provided
// for this function and not the corresponding ECC address).
// Fapi_calculateEcc is used to calculate the corresponding ECC of the data.
//
// Note that data buffer (Buffer) is aligned on 64-bit boundary for verify
// reasons.
//
// In this example, 0x100 bytes are programmed in Flash Sector6
// along with the specified ECC.
//
for(i=0, u32Index = Bzero_Sector6_start;
(u32Index < (Bzero_Sector6_start + WORDS_IN_FLASH_BUFFER));
i+= 8, u32Index+= 8)
{
//
// Point LData to the lower 64 bit data
// and HData to the higher 64 bit data
//
LData = (uint64 *)(Buffer32 + i/2);
HData = (uint64 *)(Buffer32 + i/2 + 2);
//
// Calculate ECC for lower 64 bit and higher 64 bit data
//
ECC_LB = Fapi_calculateEcc(u32Index,*LData);
ECC_HB = Fapi_calculateEcc(u32Index+4,*HData);
ECC_B = ((ECC_HB<<8) | ECC_LB);
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,Buffer+i,
8, 0, 0, Fapi_DataOnly);
//
// Wait until the Flash program operation is over
//
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Read FMSTAT register contents to know the status of FSM after
// program command to see if there are any program operation related
// errors
//
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
//Check FMSTAT and debug accordingly
FMSTAT_Fail();
}
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index, 0, 0,
&ECC_B, 2, Fapi_EccOnly);
//
// Wait until the Flash program operation is over
//
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Read FMSTAT register contents to know the status of FSM after
// program command to see if there are any program operation related
// errors
//
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
//
// Check FMSTAT and debug accordingly
//
FMSTAT_Fail();
}
Flash_enableECC(FLASH0ECC_BASE);
//
// Read back the programmed data to check if there are any ECC failures
//
dataLow = *(uint64 *)(u32Index);
Flash_ErrorStatus errorStatusLow = Flash_getLowErrorStatus(FLASH0ECC_BASE);
if((errorStatusLow != FLASH_NO_ERR) || (dataLow != *LData))
{
ECC_Fail();
}
dataHigh = *(uint64 *)(u32Index + 4);
Flash_ErrorStatus errorStatusHigh = Flash_getHighErrorStatus(FLASH0ECC_BASE);
if((errorStatusHigh != FLASH_NO_ERR) || (dataHigh != *HData))
{
ECC_Fail();
}
//
// Verify the programmed values. Check for any ECC errors.
//
oReturnCheck = Fapi_doVerify((uint32 *)u32Index,
4, Buffer32+(i/2),
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
}
}
//*****************************************************************************
// Example_ProgramUsingDataAndECC
//
// Example function to Program data in Flash using "DataAndEcc" option.
// Flash API functions used in this function are executed from RAM in this
// example.
//*****************************************************************************
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#else
#pragma CODE_SECTION(Example_ProgramUsingDataAndECC, ".TI.ramfunc");
#endif
void Example_ProgramUsingDataAndECC(void)
{
uint32 u32Index = 0;
uint16 i = 0, ECC_B = 0, ECC_LB = 0, ECC_HB = 0;
uint64 *LData, *HData, dataLow, dataHigh;
Fapi_StatusType oReturnCheck;
Fapi_FlashStatusType oFlashStatus;
Fapi_FlashStatusWordType oFlashStatusWord;
//
// Program data and ECC in Flash using "DataAndEcc" option.
// When DataAndECC option is used, Flash API will program both the supplied
// data and ECC in Flash at the address specified.
// Fapi_calculateEcc is used to calculate the corresponding ECC of the data.
//
// Note that data buffer (Buffer) is aligned on 64-bit boundary for verify
// reasons.
//
// In this example, 0x100 bytes are programmed in Flash Sector6
// along with the specified ECC.
//
for(i=0, u32Index = Bzero_Sector6_start;
(u32Index < (Bzero_Sector6_start + WORDS_IN_FLASH_BUFFER));
i+= 8, u32Index+= 8)
{
//
// Point LData to the lower 64 bit data
// and HData to the higher 64 bit data
//
LData = (uint64 *)(Buffer32 + i/2);
HData = (uint64 *)(Buffer32 + i/2 + 2);
//
// Calculate ECC for lower 64 bit and higher 64 bit data
//
ECC_LB = Fapi_calculateEcc(u32Index,*LData);
ECC_HB = Fapi_calculateEcc(u32Index+4,*HData);
ECC_B = ((ECC_HB<<8) | ECC_LB);
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,Buffer+i,
8, &ECC_B, 2, Fapi_DataAndEcc);
//
// Wait until the Flash program operation is over
//
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Read FMSTAT register contents to know the status of FSM after
// program command to see if there are any program operation related
// errors
//
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
//
// Check FMSTAT and debug accordingly
//
FMSTAT_Fail();
}
Flash_enableECC(FLASH0ECC_BASE);
//
// Read back the programmed data to check if there are any ECC failures
//
dataLow = *(uint64 *)(u32Index);
Flash_ErrorStatus errorStatusLow = Flash_getLowErrorStatus(FLASH0ECC_BASE);
if((errorStatusLow != FLASH_NO_ERR) || (dataLow != *LData))
{
ECC_Fail();
}
dataHigh = *(uint64 *)(u32Index + 4);
Flash_ErrorStatus errorStatusHigh = Flash_getHighErrorStatus(FLASH0ECC_BASE);
if((errorStatusHigh != FLASH_NO_ERR) || (dataHigh != *HData))
{
ECC_Fail();
}
//
// Verify the programmed values. Check for any ECC errors.
//
oReturnCheck = Fapi_doVerify((uint32 *)u32Index,
4, Buffer32+(i/2),
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
}
}
//*****************************************************************************
// Example_EraseSector
//
// Example function to Erase data of a sector in Flash.
// Flash API functions used in this function are executed from RAM in this
// example.
//*****************************************************************************
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#else
#pragma CODE_SECTION(Example_EraseSector, ".TI.ramfunc");
#endif
void Example_EraseSector(void)
{
Fapi_StatusType oReturnCheck;
Fapi_FlashStatusType oFlashStatus;
Fapi_FlashStatusWordType oFlashStatusWord;
//
// Erase the sector that is programmed in the above example
// Erase Sector6
//
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,
(uint32 *)Bzero_Sector6_start);
//
// Wait until FSM is done with erase sector operation
//
while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
Example_Error(oReturnCheck);
}
//
// Read FMSTAT register contents to know the status of FSM after
// erase command to see if there are any erase operation related errors
//
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
//
// Check Flash API documentation for FMSTAT and debug accordingly
// Fapi_getFsmStatus() function gives the FMSTAT register contents.
// Check to see if any of the EV bit, ESUSP bit, CSTAT bit or
// VOLTSTAT bit is set (Refer to API documentation for more details).
//
FMSTAT_Fail();
}
//
// Verify that Sector6 is erased
//
oReturnCheck = Fapi_doBlankCheck((uint32 *)Bzero_Sector6_start,
Sector64KB_u32length,
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for error info
//
Example_Error(oReturnCheck);
}
}
//******************************************************************************
// For this example, just stop here if an API error is found
//******************************************************************************
void Example_Error(Fapi_StatusType status)
{
//
// Error code will be in the status parameter
//
__asm(" ESTOP0");
}
//******************************************************************************
// For this example, once we are done just stop here
//******************************************************************************
void Example_Done(void)
{
__asm(" ESTOP0");
}
//******************************************************************************
// For this example, just stop here if FMSTAT fail occurs
//******************************************************************************
void FMSTAT_Fail(void)
{
__asm(" ESTOP0");
}
//******************************************************************************
// For this example, just stop here if ECC fail occurs
//******************************************************************************
void ECC_Fail(void)
{
__asm(" ESTOP0");
}
//
// End of File
//