Other Parts Discussed in Thread: MSP-FET
Hi,
I am getting error while code uploading in my msp430F5259 chipset project board.
Error is (")
I am work on flash memory READ/WRITE operation , while i am write data on BSL 3 and power on and off of both my project board and MSP-FET Flash Emulation tool after that this error is came continuous.
Here i provide my code which was i dump in chipset and after that i am getting this error and i can't access my device again.
#include <msp430.h>
#define Segment 1
char FW_ver = 2;
char fw;
char data[] = {0x07,0x01,0x00,0x02,0x74,0x00,0x42,0x43};
char value = 'B';
char pre_value;
_Bool FW_update_flag = 0;
void main(void)
{
WDTCTL = WDTPW+WDTHOLD;
// write_seg1(data);
read_segment();
write_Seg2(value, fw, FW_ver);
if(FW_update_flag == 1){
update_fw(data);
}
__no_operation(); // Loop forever, SET BREAKPOINT HERE
}
void read_segment()
{
char *Flash_ptr1; // Flash pointer
Flash_ptr1 = (char *)0x1801; // Initialize flash pointer
pre_value = *Flash_ptr1;
fw = pre_value;
__no_operation();
}
void write_seg1(char data[])
{
unsigned int i;
char * Flash_ptr2; // Initialize Flash pointer
Flash_ptr2 = (char *) 0x1800;
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY+ERASE; // Set Erase bit
*Flash_ptr2 = 0; // Dummy write to erase Flash seg
FCTL1 = FWKEY+WRT; // Set WRT bit for write operation
for (i = 0; i < 8; i++)
{
char pkt = data[i] ;
*Flash_ptr2++ = pkt; // Write value to flash
__no_operation();
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY+LOCK; // Set LOCK bit
__no_operation();
}
void write_Seg2(char value, char fw, char FW_ver)
{
if(fw != FW_ver)
{
__no_operation();
unsigned int i;
char * Flash_ptr3; // Initialize Flash pointer
Flash_ptr3 = (char *) 0x1600;
SYSBSLC = FWKEY+SYSBSLPE;
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY+ERASE; // Set Erase bit
*Flash_ptr3 = 0; // Dummy write to erase Flash seg
FCTL1 = FWKEY+WRT; // Set WRT bit for write operation
for(i = 0; i < (Segment*512); i++)
{
*Flash_ptr3++ = value; // Write value to flash
__no_operation();
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY+LOCK; // Set LOCK bit
__no_operation();
data[1] = FW_ver;
FW_update_flag = 1;
}
}
void update_fw(char data[])
{
unsigned int i;
char * Flash_ptr4; // Initialize Flash pointer
Flash_ptr4 = (char *) 0x1800;
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY+ERASE; // Set Erase bit
*Flash_ptr4 = 0; // Dummy write to erase Flash seg
FCTL1 = FWKEY+WRT; // Set WRT bit for write operation
for (i = 0; i < 8; i++)
{
char pkt = data[i] ;
*Flash_ptr4++ = pkt; // Write value to flash
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY+LOCK; // Set LOCK bit
FW_update_flag = 0;
}
Can anyone help me out to solve my problem.
It will grateful to me.