//******************************************************************************
// MSP430G2xx1 Demo - Flash In-System Programming, Copy SegC to SegD
//
// Description: This program first erases flash seg C, then it increments all
// values in seg C, then it erases seg D, then copies seg C to seg D.
// Assumed MCLK 771kHz - 1428kHz.
// //* Set Breakpoint on NOP in the Mainloop to avoid Stressing Flash *//
//
// MSP430G2xx1
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
//
// D. Dang
// Texas Instruments Inc.
// October 2010
// Built with CCS Version 4.2.0 and IAR Embedded Workbench Version: 5.10
//******************************************************************************
#include
char value; // 8-bit value to write to segment A
// Function prototypes
void write_SegC (char value);
void copy_C2D (void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // 关闭看门狗
// if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
// {
// while(1); // If calibration constants erased
// do not load, trap CPU!!
// }
BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator
value = 1; // initialize value
while(1) // Repeat forever
{
write_SegC(value++); // Write segment C, increment value
copy_C2D(); // Copy segment C to D
_NOP(); // SET BREAKPOINT HERE
}
}