TI中文支持网
TI专业的中文技术问题搜集分享网站

msp430读写info flash

msp430f4152的datasheet里有句话说, The flash timing generator operating frequency, fFTG, must be in the range from ~ 257 kHz to ~ 476 kHz,这个意思是由FSSELx选定的时钟频率必须在这个区间,擦写FLASH操作才能稳定进行是吗?

灰小子:

是的。由这两个寄存器配置时钟频率

FSSELx:时钟模式 FNx:时钟分频

Cache Yo:

回复 灰小子:

感谢回答。那么我在低功耗应用场合外接32k晶振作为时钟,如何得到合适的频率范围呢?

Cache Yo:

回复 灰小子:

感谢回答。那么我在低功耗应用场合外接32k晶振作为时钟,如何得到合适的频率范围呢?

灰小子:

回复 Cache Yo:

可以参考这个例程

//******************************************************************************// MSP430F41x2 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.// ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz// //* Set Breakpoint on NOP in the Mainloop to avoid Stressing Flash *////// MSP430F41x2// —————–// /|\| XIN|-// | | |// –|RST XOUT|-// | |//// P. Thanigai// Texas Instruments Inc.// January 2009// Built with CCE Version: 3.1 and IAR Embedded Workbench Version: 4.11//******************************************************************************#include <msp430.h>

char value; // 8-bit value to write to seg C

// Function prototypesvoid write_SegC(char value);void copy_C2D(void);

int main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator value = 0; // initialize value

while(1) // Repeat forever { write_SegC(value++); // Write segment C, increment value copy_C2D(); // Copy segment C to D __no_operation(); // SET BREAKPOINT HERE }}

void write_SegC(char value){ char *Flash_ptr; // Flash pointer unsigned int i;

Flash_ptr = (char *)0x1040; // Initialize Flash pointer FCTL3 = FWKEY; // Clear Lock bit FCTL1 = FWKEY + ERASE; // Set Erase bit *Flash_ptr = 0; // Dummy write to erase Flash seg

FCTL1 = FWKEY + WRT; // Set WRT bit for write operation

for (i = 0; i < 64; i++) { *Flash_ptr++ = value; // Write value to flash }

FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit}

void copy_C2D(void){ char *Flash_ptrC; // Segment C pointer char *Flash_ptrD; // Segment D pointer unsigned int i;

Flash_ptrC = (char *)0x1040; // Initialize Flash segment C ptr Flash_ptrD = (char *)0x1000; // Initialize Flash segment D ptr FCTL3 = FWKEY; // Clear Lock bit FCTL1 = FWKEY + ERASE; // Set Erase bit *Flash_ptrD = 0; // Dummy write to erase Flash seg D FCTL1 = FWKEY + WRT; // Set WRT bit for write operation

for (i = 0; i < 64; i++) { *Flash_ptrD++ = *Flash_ptrC++; // copy value segment C to seg D }

FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit}

赞(0)
未经允许不得转载:TI中文支持网 » msp430读写info flash
分享到: 更多 (0)