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.

CC2544: Can not write flash in 0x7c00(32 page)

Part Number: CC2544
Other Parts Discussed in Thread: CC2541

Hi ,

I have met on issue : when I try to write flash Page31 and page 32like below code

1 run at IAR debug mode , All run OK; 

2 program by ""Flash programmer", the data in flash page 32 is OK, but the data in Flash page 32 is fail , please help to find out the issue

 __xdata uint8 ramdon_number[8];

/******************************************************************************
* @fn main
*
* @brief ...
*
* @return none
******************************************************************************/
void main(void) {

// Initialise board peripherals
halBoardInit();
Hal_getRnd(ramdon_number,8); //1st get 8 ramdon numbers


flash_dma_save((char *)ramdon_number,(unsigned short *)0x7800,8);
P0_1=~P0_1; //work done, save data into 0x7800 flash 


flash_dma_save((char *)ramdon_number,(unsigned short *)0x7C00,8);
P0_1=~P0_1; //this code not run, no data in flash 0x7C00 (Program by Flash Programer)

}

 

uint8 flash_dma_save(char *data_in,unsigned short *data_out,uint16 datasize)
{
DMA_DESC dmaConfig0;
/* Configure DMA channel 0:
* SRCADDR: address of the data to be written to flash (increasing).
* DESTADDR: the flash controller data register (fixed), so that the
* flash controller will write this data to flash.
* vlen: use LEN for transfer count.
* LEN: equal to the number of bytes to be transferred.
* WORDSIZE: each transfer should transfer one byte.
* TMODE: should be set to single mode (see datasheet, DMA Flash Write).
* Each flash write complete will re-trigger the DMA channel.
* TRIG: let the DMA channel be triggered by flash data write complete
* (trigger number 18). That is, the flash controller will trigger
* the DMA channel when the Flash Write Data register, FWDATA, is
* ready to receive new data.
* SRCINC: increment by one byte.
* DESTINC: fixed (always write to FWDATA).
* IRQMASK: disable interrupts from this channel.
* M8: 0, irrelevant since we use LEN for transfer count.
* PRIORITY: high.
*/
// bool ok_flag=false;
dmaConfig0.srcAddrH = ((uint16)data_in >> 8) & 0x00FF;
dmaConfig0.srcAddrL = (uint16)data_in & 0x00FF;
dmaConfig0.destAddrH = ((uint16)&FWDATA >> 8) & 0x00FF;
dmaConfig0.destAddrL = (uint16)&FWDATA & 0x00FF;
dmaConfig0.vlen = DMA_VLEN_USE_LEN;
dmaConfig0.lenH = (datasize >> 8) & 0x00FF;
dmaConfig0.lenL = datasize & 0x00FF;
dmaConfig0.wordSize = DMA_WORDSIZE_BYTE;
dmaConfig0.tMode = DMA_TMODE_SINGLE;
dmaConfig0.trig = DMA_TRIG_FLASH;
dmaConfig0.srcInc = DMA_SRCINC_1;
dmaConfig0.destInc = DMA_DESTINC_0;
dmaConfig0.irqMask = DMA_IRQMASK_ENABLE;
dmaConfig0.m8 = DMA_M8_USE_8_BITS;
dmaConfig0.priority = DMA_PRI_HIGH;

/* The DMA configuration data structure may reside at any location in
* unified memory space, and the address location is passed to the DMA
* through DMA0CFGH:DMA0CFGL.
*/
DMA0CFGH = ((uint16)&dmaConfig0 >> 8) & 0x00FF;
DMA0CFGL = (uint16)&dmaConfig0 & 0x00FF;

// Waiting for the flash controller to be ready.
while (FCTL & FCTL_BUSY);

/* Configuring the flash controller.
* FADDRH:FADDRL: point to the area in flash to write to.
*/
uint16 addr;
addr = (uint16)data_out >> 2; // You address 32-bit words through the flash controller.

FADDRH = (addr >> 8) & 0x00FF;
FADDRL = addr & 0x00FF;

// if(erase_flag)
// {
// // Erase the page that will be written to.
// FCTL |= FCTL_ERASE;
//
// // Wait for the erase operation to complete.
// while (FCTL & FCTL_BUSY);
// }

// Arm the DMA channel, takes 9 system clock cycles.
DMAARM |= DMAARM_DMAARM0;
NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); // 9 NOPs

// Enable flash write. Generates a DMA trigger.
FCTL |= FCTL_WRITE;

// Wait for DMA transfer to complete.
while (!(DMAIRQ & DMAIRQ_DMAIF0));

// Wait until flash controller not busy.
while (FCTL & (FCTL_BUSY | FCTL_FULL));

/* By now, the transfer is completed, so the transfer count is reached.
* The DMA channel 0 interrupt flag is then set, so we clear it here.
*/
DMAIRQ = ~DMAIRQ_DMAIF0; // Clear interrupt flag by R/W0, see datasheet.


// End function with infinite loop (for debugging purposes).
return true;
}

 

  • The last flash page ( page 31, address from 0x7C00 to 0X7FFF) can only be written to by use of the debug interface. It can be read from SW though XDATA and through the debug interface. i.e. you cannot write to the last flash page through SW.

    This is stated in the user guide at page 57:

    3.4.1 Lock Bits
    For software and/or access protection, a set of lock bits can be written to the upper available flash
    page—the lock-bit page. The lock-bit structure consists of FLASH_PAGES-1 lock bits followed by one
    debug lock bit (see Table 3-5). The structure starts at address (flash-page size in bytes - 16) in the lock-bit
    page and occupies up to 16 bytes. The rest of the lock-bit page (addresses 0–(flash-page size in bytes -
    17)) can be used to store code/constants, but cannot be changed without entering debug mode.
  • Hi Eirik,

    Thanks I see now, and which version guideline do you use? mine is " CC2543, CC2544, CC2545 System-on-Chip Solution for 2.4-GHz Apps User's Guide (Rev. B)"

    3.4.1 Lock Bits
    For software and/or access protection, a set of lock bits can be written to the upper available flash
    page—the lock-bit page. The lock-bit structure consists of 128 bits where the first 31 each corresponds to
    the first 31 flash pages available in the device. The last bit (at the highest address) is the debug lock bit
    (see Table 3-5). The structure starts at CODE address 0x7FF0 ( address 0xFFF0 in XDATA ) in the lockbit
    page and occupies 16 bytes. The rest of the lock-bit page can be used to store code/constants, but
    cannot be changed without entering debug mode.

  • I copy/pasted old material. Your version is latest and greatest.
  • HI Eirik,

    Do you have the Document about the command line for SmartRFProgConsole?So i can write my data to the page32

    By the way,Do you know CC2544 have a random address in the infopage? if yes, how can i get it? thanks
  • Hello Gandy,
    There is no IEEE MAC address like there is on CC2541.
    refer to 6 Command Line Interface in the user manual:
    C:\Program Files (x86)\Texas Instruments\SmartRF Tools\Flash Programmer\doc\
  • Hi Eirik,
    I have read manual, but it's only tell how config in IAR.I want to the manual in DOS, so i can make a bat file to auto program.
  • Just run this in cmd window to get the help text:
    C:\Program Files (x86)\Texas Instruments\SmartRF Tools\Flash Programmer\bin\SmartRFProgConsole.exe
  • done now,thanks very much!