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.

TMS320F28027: Flash_program using Flash_API

Part Number: TMS320F28027
Other Parts Discussed in Thread: CONTROLSUITE

I was wondering how I could program the mcu flash.

I have imported the 2802x_FlashAPI_BootROMSymbols_v2.01.lib into my project, and included the flash api v201a includes.

I called the version check in my code and I was able to get the 2.01 as the floating value. 

But when I try to program the flash it halts. I can see that I am clearing the flash at the particular location I am trying to write at (Sector C) and I am doing a simple program flash as seen in the flash api example:

5381.Example_2802xLEDBlink.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//#############################################################################
//
// File: Example_F2802xLedBlink.c
//
// Title: F2802x LED Blink Getting Started Program.
//
//! \addtogroup example_list
//! <h1>LED Blink</h1>
//!
//! This example configures CPU Timer0 for a 500 msec period, and toggles
//! the GPIO0-4 LEDs once per interrupt. For testing purposes, this example
//! also increments a counter each time the timer asserts an interrupt.
//!
//! Watch Variables:
//! - interruptCount
//!
//! Monitor the GPIO0-4 LEDs blink on (for 500 msec) and off (for 500 msec)
//! on the 2802x0 control card.
//
//#############################################################################
// $TI Release: F2802x Support Library v230 $
// $Release Date: Fri May 8 07:43:05 CDT 2015 $
// $Copyright: Copyright (C) 2008-2015 Texas Instruments Incorporated -
// http://www.ti.com/ ALL RIGHTS RESERVED $
//#############################################################################
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#include "Flash2802x_API_Library.h"
//#include "Flash2802x_API_Config.h"
//#include "F2802x_BootVars.h"
#include "f2802x_common/include/adc.h"
#include "f2802x_common/include/clk.h"
#include "f2802x_common/include/flash.h"
#include "f2802x_common/include/gpio.h"
#include "f2802x_common/include/pie.h"
#include "f2802x_common/include/pll.h"
#include "f2802x_common/include/timer.h"
#include "f2802x_common/include/wdog.h"
// Prototype statements for functions found within this file.
__interrupt void cpu_timer0_isr(void);
#define Flash_API
#ifdef Flash_API
uint16_t interruptCount = 0;
uint16_t myValues = 0x0;
typedef struct {
Uint16 *StartAddr;
Uint16 *EndAddr;
} SECTOR;
#define WORDS_IN_FLASH_BUFFER 0x010
uint16_t Buffer[WORDS_IN_FLASH_BUFFER];
uint16_t i;
uint16_t Status;
uint16_t *Flash_ptr; // Pointer to a location in flash
uint16_t Length; // Number of 16-bit values to be programmed
float32 Version; // Version of the API in floating point
uint16_t VersionHex; // Version of the API in decimal encoded hex
FLASH_ST FlashStatus;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 After it halts it resets all the flash sectors to 0x0000. Am i doing something wrong ?  

Also, if I am using the bootROM library, i do not need to add any of the sections in my .cmd file, is this correct ?  

Please advise how I could write one word to the flash sector C.  

Regards,  

Rajan Joshi

  • Are you using below example project found in controlSuite? Also, have you made any changes?

    <controlSUITE>\libs\utilities\flash_api\2802x\v201a\example_ccsv5


    Regards,

    Manoj

  • Yes Manoj,

    I have used that example and it works on my device. I am trying to use the flash_API in another project.

    When I try to call any other function other than flahsAPIVersion() I get an error.

    If you look at my source code file you can see that I have used the Flash_Program function but I am not sure if I need to do any additional steps to make the erase and write work.

    Please advise.
  • Rajan,

    1) Are you executing the Flash API functions from RAM (or) flash?

    2) Did you single step through the code in assembly mode and find which instruction is causing the error? I'm wondering whether you are executing illegal opcode

    3) Did you make sure to follow all the recommendations provided in the documentation in example?

    Regards,

    Manoj

  • 1) Are you executing the Flash API functions from RAM (or) flash?

    I am currently running from RAM, using the bootROM library.

    2) Did you single step through the code in assembly mode and find which instruction is causing the error? I'm wondering whether you are executing illegal opcode

    Yes, I did single step through the code and I was able to pin point it to the erase instruction.


    3) Did you make sure to follow all the recommendations provided in the documentation in example?

    Yes, I copied all the code from the example Erase function and it still failed.


    However, you are right on your second question, I was executing an illegal ISR. This may have caused the error. I read in the document that I should stay away from triggering interrupts while reading or writing to flash.

    Anyways, I was able to erase and write to flash after I removed the ISR.
  • Rajan,

    Good. Is the issue resolved?

    Can I close this thread?

    Regards,

    Manoj

  • Yes Manoj, i think the thread could be closed.
  • Hey Manoj,

    Sorry to open this thread up again but I was wondering if there is a way of stopping all interrupt routines and starting it again when the code has been executed (in my case writing to flash)?

    Rajan Joshi
  • Rajan,

    Use asm(" SETC INTM") to globally disable interrupts and use asm(" CLRC INTM") to globally re-enable interrupts.

    Regards,
    Manoj