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.
Original question:
CC2544: Sample code about Radio Test mode for CC2544
Replies: 8
Views: 623
Part Number: CC2544
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;}
Best Regards, Eirik Please refer to the resources and abbreviations below for explanations and answers to many questions.
SLA - Simplelink Academy, SCS - Sensor Controller Studio, SC - Sensor Controller, TI Cloud Tools, Resource Explorer, Bluetooth low energy software stack, Bluetooth low energy software stack archive, TI BLE Wiki (OLD), BLE Getting Started and FAQ, CC1352R and CC26x2R Intro, Bluetooth SIG Core Spec, CC2640R2F SDG, CC26X2 SDG, CC2650/CC2640 SDG, BLE PACKET SNIFFER
In reply to Eirik V:
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 BitsFor software and/or access protection, a set of lock bits can be written to the upper available flashpage—the lock-bit page. The lock-bit structure consists of 128 bits where the first 31 each corresponds tothe 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 lockbitpage and occupies 16 bytes. The rest of the lock-bit page can be used to store code/constants, butcannot be changed without entering debug mode.
In reply to Gandy: