共2条
1/1 1 跳转至页
45DB,FLASH,430 请求朋友帮忙啊 麻烦给个完整的 45DB FLASH 的430读写程序
问
请求朋友帮忙啊 麻烦给个完整的 45DB FLASH 的430读写程序
非常的感谢 答 1: #include <msp430x44x.h>
char value; // 8-bit value to write to segment A
// Function prototypes
void write_SegA (char value);
void copy_A2B (void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
FCTL2 = FWKEY + FSSEL0 + FN0; // MCLK/2 for Flash Timing Generator
value = 0; // initialize value
while(1) // Repeat forever
{
write_SegA(value++); // Write segment A, increment value
copy_A2B(); // Copy segment A to B
}
}
void write_SegA (char value)
{
char *Flash_ptr; // Flash pointer
unsigned int i;
Flash_ptr = (char *) 0x1080; // Initialize Flash pointer
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
*Flash_ptr = 0; // Dummy write to erase Flash segment
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
for (i=0; i<128; i++)
{
*Flash_ptr++ = value; // Write value to flash
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Reset LOCK bit
}
void copy_A2B (void)
{
char *Flash_ptrA; // Segment A pointer
char *Flash_ptrB; // Segment B pointer
unsigned int i;
Flash_ptrA = (char *) 0x1080; // Initialize Flash segment A pointer
Flash_ptrB = (char *) 0x1000; // Initialize Flash segment B pointer
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
*Flash_ptrB = 0; // Dummy write to erase Flash segment B
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
for (i=0; i<128; i++)
{
*Flash_ptrB++ = *Flash_ptrA++; // copy value segment A to segment B
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Reset LOCK bit
} 答 2: ???
at45db
我也在找 答 3: #include "msp430x44x.h"
//*********************************************************************
//
// MSP430F449
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|- ________
// | | | |
// | P6.0|-->| A |
// | P6.1| . | T |
// | P6.2| . | 4 |
// | P6.3| . | 5 |
// | P6.4| . | D |
// | P6.5| . | B |
// | P6.6|-->| 0 |
// | | | 4 |
// | | | 1 |
// |________|
// Built with IAR Embedded Workbench Version: 1.26B
//*******************************************************************
int word;
int cmd_word;
int R_word;
int tab[16]={0x21,0x22,0x23,0x24,0x25,0x26};
int *Ram_addr;
int *Buff_addr;
void Send_Byte(void)
{
int i;
int Tamp;
for (i=0;i<8;i++)
{
P6OUT &= 0xDF;
Tamp = word;
Tamp &= 0x80;
if(!Tamp)
P6OUT &= 0xEF;
else
P6OUT |= 0x10;
P6OUT |= 0x20;
word = word << 1;
}
}
void Send_Start(void)
{
P6DIR |= 0X30;
P6OUT |= 0X20;
word = cmd_word;
Send_Byte();
}
void Stop(void)
{
P6DIR &= 0X00;
P6DIR |= 0X63;
P6OUT |= 0X63;
}
void Flash_B_Write(void)
{
int j;
P6DIR |= 0X40;
P6OUT &= 0XBF;
cmd_word = 0x84;
Send_Start();
word = 0x00;
Send_Byte();
word = 0x00;
Send_Byte();
word = 0x1A;
Send_Byte();
for(j=0;j<16;j++)
{
word = tab[j];
Send_Byte();
}
Buff_addr = (int *)0x1A;
Stop();
}
void Receive_Byte(void)
{
int i;
P6DIR |= 0X20;
P6DIR &= 0XF7;
R_word = 0x00;
P6OUT &= 0xBF;
for(i=0;i<8;i++)
{
P6OUT &= 0xDF;
P6OUT |= 0X20;
if(P6IN & 0x08)
R_word |= 0x01;
else
R_word &= 0xFE;
P6OUT &= 0xDF;
R_word = R_word << 1;
}
R_word = R_word >> 1;
}
void Flash_B_Read(void)
{
int j;
P6DIR |= 0X40;//CS out
P6OUT &= 0XBF;
cmd_word = 0x54;
Send_Start();
word = 0x00;
Send_Byte();
word = 0x00;
Send_Byte();
word = 0x1A;
Send_Byte();
word = 0xff;
Send_Byte();
for(j=0;j<16;j++)
{
Receive_Byte();
*Ram_addr++ = R_word;
}
Stop();
}
void main(void)
{
while(1){
int m = 0x7fff;
WDTCTL = WDTPW + WDTHOLD;
FLL_CTL1 = SELM_A + FLL_DIV_8;
P6DIR &= 0X00;
P6SEL &= 0X00;
P6DIR |= 0X63;
P6OUT |= 0X63;
Flash_B_Write();
while(m-- > 0);
Ram_addr = (int *)0x270;
Flash_B_Read();
}
}
非常的感谢 答 1: #include <msp430x44x.h>
char value; // 8-bit value to write to segment A
// Function prototypes
void write_SegA (char value);
void copy_A2B (void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
FCTL2 = FWKEY + FSSEL0 + FN0; // MCLK/2 for Flash Timing Generator
value = 0; // initialize value
while(1) // Repeat forever
{
write_SegA(value++); // Write segment A, increment value
copy_A2B(); // Copy segment A to B
}
}
void write_SegA (char value)
{
char *Flash_ptr; // Flash pointer
unsigned int i;
Flash_ptr = (char *) 0x1080; // Initialize Flash pointer
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
*Flash_ptr = 0; // Dummy write to erase Flash segment
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
for (i=0; i<128; i++)
{
*Flash_ptr++ = value; // Write value to flash
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Reset LOCK bit
}
void copy_A2B (void)
{
char *Flash_ptrA; // Segment A pointer
char *Flash_ptrB; // Segment B pointer
unsigned int i;
Flash_ptrA = (char *) 0x1080; // Initialize Flash segment A pointer
Flash_ptrB = (char *) 0x1000; // Initialize Flash segment B pointer
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
*Flash_ptrB = 0; // Dummy write to erase Flash segment B
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
for (i=0; i<128; i++)
{
*Flash_ptrB++ = *Flash_ptrA++; // copy value segment A to segment B
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Reset LOCK bit
} 答 2: ???
at45db
我也在找 答 3: #include "msp430x44x.h"
//*********************************************************************
//
// MSP430F449
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|- ________
// | | | |
// | P6.0|-->| A |
// | P6.1| . | T |
// | P6.2| . | 4 |
// | P6.3| . | 5 |
// | P6.4| . | D |
// | P6.5| . | B |
// | P6.6|-->| 0 |
// | | | 4 |
// | | | 1 |
// |________|
// Built with IAR Embedded Workbench Version: 1.26B
//*******************************************************************
int word;
int cmd_word;
int R_word;
int tab[16]={0x21,0x22,0x23,0x24,0x25,0x26};
int *Ram_addr;
int *Buff_addr;
void Send_Byte(void)
{
int i;
int Tamp;
for (i=0;i<8;i++)
{
P6OUT &= 0xDF;
Tamp = word;
Tamp &= 0x80;
if(!Tamp)
P6OUT &= 0xEF;
else
P6OUT |= 0x10;
P6OUT |= 0x20;
word = word << 1;
}
}
void Send_Start(void)
{
P6DIR |= 0X30;
P6OUT |= 0X20;
word = cmd_word;
Send_Byte();
}
void Stop(void)
{
P6DIR &= 0X00;
P6DIR |= 0X63;
P6OUT |= 0X63;
}
void Flash_B_Write(void)
{
int j;
P6DIR |= 0X40;
P6OUT &= 0XBF;
cmd_word = 0x84;
Send_Start();
word = 0x00;
Send_Byte();
word = 0x00;
Send_Byte();
word = 0x1A;
Send_Byte();
for(j=0;j<16;j++)
{
word = tab[j];
Send_Byte();
}
Buff_addr = (int *)0x1A;
Stop();
}
void Receive_Byte(void)
{
int i;
P6DIR |= 0X20;
P6DIR &= 0XF7;
R_word = 0x00;
P6OUT &= 0xBF;
for(i=0;i<8;i++)
{
P6OUT &= 0xDF;
P6OUT |= 0X20;
if(P6IN & 0x08)
R_word |= 0x01;
else
R_word &= 0xFE;
P6OUT &= 0xDF;
R_word = R_word << 1;
}
R_word = R_word >> 1;
}
void Flash_B_Read(void)
{
int j;
P6DIR |= 0X40;//CS out
P6OUT &= 0XBF;
cmd_word = 0x54;
Send_Start();
word = 0x00;
Send_Byte();
word = 0x00;
Send_Byte();
word = 0x1A;
Send_Byte();
word = 0xff;
Send_Byte();
for(j=0;j<16;j++)
{
Receive_Byte();
*Ram_addr++ = R_word;
}
Stop();
}
void main(void)
{
while(1){
int m = 0x7fff;
WDTCTL = WDTPW + WDTHOLD;
FLL_CTL1 = SELM_A + FLL_DIV_8;
P6DIR &= 0X00;
P6SEL &= 0X00;
P6DIR |= 0X63;
P6OUT |= 0X63;
Flash_B_Write();
while(m-- > 0);
Ram_addr = (int *)0x270;
Flash_B_Read();
}
}
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |