I have some trouble with the flash read and write on CC2640.Although i have read carefully all the relative topics,i faile to find my solution.
I am trying to realize the IAP(in application program) function on cc2640 through UART. I can write some certain bytes to the internal flash by the funtions FlashProgram() and FlashSectorErase() in the dirverlib. but the write funtion can be called only one time, and then the uart stop echo to my input. The erase function can be called rightly.some key functions I used is listed bellow:
//Power on the VIMS domain at task_init
PRCM_PowerDomainOn(PRCM_DOMAIN_VIMS);
//************************************//
//flash erase
void flash_erase(void)
{
//addr begin to erase
uint32_t addr = 0x0000b000;
//disable interrupts
IntDisable(49);
//do flash sector erase
if(FlashSectorErase(addr) == 0)
printf("erase ok!\r\n");
//re-enable interrupts
IntEnable(49);
}
//flash write
void flash_write(void)
{
//addr begin to write
uint32_t addr = 0x0000b000;
//counters
uint16_t i = 0;
//data to write
uint8_t data[256] = {0};
//fill the data buff
for(i = 0; i < 256; i++)
data[i] = i;
//disable interrupts
IntDisable(49);
//do flash write
if(FlashProgram(data,addr,256) == 0)
printf("flash write ok!\r\n");
//re-enable interrupts
IntEnable(49);
}
Where did I make mistakes? Besides,I couled not find the read function in the driverlib, and tried the HalFlashRead(),but it only work when the page is 29 or 30.I don't know why.