Hi, I'm trying to store some data into the information page of the flash memory on CC2541. (I do not want to use DMA.)
My current code (which is not working...) is as follow:
EA = 0; /* disable interrupts */ while (FCTL & 0x80); /* poll FCTL.BUSY and wait until flash controller is ready */ FADDRH = 0x7E; //((addr >> 8) & 0x00FF); FADDRL = 0; //addr & 0x00FF; FCTL |= 0x01; /* set FCTL.ERASE bit to start page erase */ while (FCTL & 0x80); /* optional: wait until flash write has completed (~20 ms) */ EA = 1; /* enable interrupts */ while (FCTL & 0x80); FADDRH = 0x7E; //((addr >> 8) & 0x00FF); FADDRL = 0; //addr & 0x00FF; FCTL |= 0x02; FWDATA = 0x63; //random number for testing. but it always fails to write into the flash. FFFF is always returned. while (FCTL & 0x80);
//the codes below are dummy codes to make sure the complile will not optimise. hhh=1; jjj= *abcde; if (*abcde >30 && hhh>jjj) { P1DIR = 0; }