SLAU320AJ July 2010 – May 2021
Reference function: WriteFLASH
This section describes one method available to program the flash memory module in an MSP430 device. It uses the same procedure that user-defined application software would use, which would be programmed into a production-equipment MSP430 device. Nonconsecutive flash memory addressing is supported.
This programming method requires a TCLK frequency of 350 kHz ±100 kHz while the erase or programming cycle is being executed. The frequency that must be applied to SBWTCK in Spy-Bi-Wire mode is the same frequency that is applied to TCK in 4-wire mode.
For more information on the flash controller timing, see the corresponding MSP430 user's guide and device-specific data sheet. Table 2-9 shows the required minimum number of TCLK cycles, depending on the action performed on the flash (for FCTL2 register bits 0 to 7 = 0x40 as defined in the MSP430 user's guide).
Flash Action | Minimum TCLK Count |
---|---|
Segment erase | 4820 (default) or 9628 (MSP430ixx family) |
Mass erase | 5300 to 10600(1) |
Program word | 35 |
The following JTAG communication flow shows programming of the MSP430 flash memory using the onboard flash controller. In this implementation, 16-bit words are programmed into the main flash memory area. To program bytes, the BYTE bit in the JTAG CNTRL_SIG register must be set high while in programming mode. StartAddr is the starting address of the flash memory array to be programmed.
Switch CPU to stopped state (HaltCPU) | ||||
ClrTCLK | ||||
IR_SHIFT("IR_CNTRL_SIG_16BIT") | ||||
DR_SHIFT16(0x2408) | : Set RW to Write | |||
IR_SHIFT("IR_ADDR_16BIT") | ||||
DR_SHIFT16(0x0128)
(1) | : Point to FCTL1 Address | |||
IR_SHIFT("IR_DATA_TO_ADDR") | ||||
DR_SHIFT16(0xA540) | : Enable FLASH Write Access | |||
SetTCLK | ||||
ClrTCLK | ||||
IR_SHIFT("IR_ADDR_16BIT") | ||||
DR_SHIFT16(0x012A)
(1) | : Point to FCTL2 Address | |||
IR_SHIFT("IR_DATA_TO_ADDR") | ||||
DR_SHIFT16(0xA540) | : Source is MCLK, divider by 1 | |||
SetTCLK | ||||
ClrTCLK | ||||
IR_SHIFT("IR_ADDR_16BIT") | ||||
DR_SHIFT16(0x012C)
(1) | : Point to FCTL3 Address | |||
IR_SHIFT("IR_DATA_TO_ADDR") | ||||
DR_SHIFT16(0xA500)
(2) | : Clear FCTL3 Register | |||
SetTCLK | ||||
ClrTCLK | ||||
IR_SHIFT("IR_CNTRL_SIG_16BIT") | ||||
DR_SHIFT16(0x2408) | : Set RW to Write | Yes | ||
IR_SHIFT("IR_ADDR_16BIT") | ||||
DR_SHIFT16("Address")
(1) | : Set Address for Write | |||
IR_SHIFT("IR_DATA_TO_ADDR") | ||||
DR_SHIFT16("Data") | : Set Data for Write | |||
SetTCLK | ||||
ClrTCLK | ||||
IR_SHIFT("IR_CNTRL_SIG_16BIT") | ||||
DR_SHIFT16(0x2409) | : Set RW to Read | |||
SetTCLK | Repeat 35 times (3) | |||
ClrTCLK | ||||
Write Another Flash Address? | ||||
No | ||||
IR_SHIFT("IR_CNTRL_SIG_16BIT") | ||||
DR_SHIFT16(0x2408) | : Set RW to Write | |||
IR_SHIFT("IR_ADDR_16BIT") | ||||
DR_SHIFT16(0x0128)
(1) | : Point to FCTL1 Address | |||
IR_SHIFT("IR_DATA_TO_ADDR") | ||||
DR_SHIFT16(0xA500) | : Disable FLASH Write Access | |||
SetTCLK | ||||
ClrTCLK | ||||
IR_SHIFT("IR_ADDR_16BIT") | ||||
DR_SHIFT16(0x012C)
(1) | : Point to FCTL3 Address | |||
IR_SHIFT("IR_DATA_TO_ADDR") | ||||
DR_SHIFT16(0xA510)
(4) | : Set LOCK bit in FCTL3 | |||
SetTCLK | ||||
ReleaseCPU should now be executed, returning the CPU to normal operation. |