MSP430 5xx-flash Beyond the range of 64K addresses to read a(5)

发布时间:2021-06-05

5xx-超出64 k地址的flash 读和写和segment A 的读写理解

write_SegA(value); //The state of the LOCKA bit is toggled when a 1 is written to it. //Writing a 0 to LOCKA has no effect.

copy_C2D(); // Copy segment C to D

value = 10; write_Seg_1(value);

Read_Flash(128); //Read 0x10000-0x10080

while(1); // Loop forever, SET BREAKPOINT HERE }

void Read_Flash(unsigned int NUM) {

unsigned int counter;

unsigned char *Flash_ptrC; // Initialize Flash pointer

Flash_ptrC = (unsigned char *) 0x10000; // SegC

for (counter = 0; counter < NUM; counter++) {

TEM_data[counter] = *Flash_ptrC ++; //Read flash to Data[Num] } }

void write_SegA(char value) {

unsigned int i;

//unsigned int *Flash_ptr = (unsigned int *)0x10000;

char * Flash_ptr; // Initialize Flash pointer Flash_ptr = (char *) 0x1980;

__disable_interrupt(); // 5xx Workaround: Disable global // interrupt while erasing. Re-Enable // GIE if needed FCTL3 = FWKEY+LOCKA; // Clear Lock bit FCTL1 = FWKEY+ERASE; // Set Erase bit

*(unsigned int *)Flash_ptr = 0; // Dummy write to erase Flash seg FCTL1 = FWKEY+WRT; // Set WRT bit for write operation

for (i = 0; i < 128; i++) {

*Flash_ptr++ = value++; // Write value to flash

精彩图片

热门精选

大家正在看