M0的菜鸟,在研究FMC dataflash,目的想把0x55放到0x1f000的位置,把0xaa放到0x1f100的位置。问题是执行
FMC_Write(0x1f000, 0x55);再执行FMC_Write(0x1f100, 0xAA);然后FMC_Read(0x1f000, &u32Data);此时是u32Data=0xAA.
按道理说0x55才对。不知道问题到底出现在哪里请大师指点迷冿。
到代码如下:
******************************************************************************/
#include <stdio.h>
#include "nano1xx.h"
#include "nano1xx_fmc.h"
void delay_ms(uint32_t count);
/*---------------------------------------------------------------------------------------------------------*/
/* Main Function */
/*---------------------------------------------------------------------------------------------------------*/
int32_t main (void)
{
int32_t i32Err=0;
uint32_t u32Data;
uint32_t u32Data0;
// uint32_t apBase, apLimit;
/// uint32_t config0Bak, config1Bak;
printf("+------------------------------------------------------+\n");
printf("| NANO1xx FMC Driver Sample Code for LDROM |\n");
printf("+------------------------------------------------------+\n");
UNLOCKREG();
/* Enable FMC ISP function */
FMC_Init();
/* Read BS */
printf(" Boot Mode .......................... ");
if (FMC_GetBootSelect() == E_FMC_APROM)
{
printf("[APROM]\n");
printf(" WARNING: This code should be in LD mode but it is in AP mode now.\n");
while(1);
}
else
printf("[LDROM]\n");
/* Read Data Flash base address */
u32Data = FMC_ReadDataFlashBaseAddr();
printf(" Data Flash Base Address ............ [0x%08x]\n", u32Data);
FMC_Erase(0x1f000);
delay_ms(10);
FMC_Read(0x1f000, &u32Data);
FMC_Write(0x1f000, 0x55);
delay_ms(10);
FMC_Read(0x1f100, &u32Data0);
FMC_Write(0x1f100, 0xAA);
delay_ms(10);
FMC_Read(0x1f000, &u32Data);
if(u32Data == 0x55)
{
printf(" Data Flash Base Address ............ [0x%08x]\n", u32Data);
i32Err=FMC_Read(0x1f100, &u32Data0);
if(i32Err==0)
printf(" Data Flash Base Address ............ [0x%08x]\n", u32Data0);
while(1);
}
}
/*************************************************************************************
** Function name: delay_ms
** Descriptions: 1ms(晶振为12MHZ)延时子程序
** input parameters: count
** output parameters: 无
** Returned value: 无
*************************************************************************************/
void delay_ms(uint32_t count)
{
uint32_t i,j;
for(i=count;i>0;i--)
for(j=2395;j>0;j--);
} |