dfc.c

来自「最新版IAR FOR ARM(EWARM)5.11中的代码例子」· C语言 代码 · 共 82 行

C
82
字号
/*************************************************************************
 *
 *    Used with ICCARM and AARM.
 *
 *    (c) Copyright IAR Systems 2007
 *
 *    File name   : dfc.c
 *    Description : Main file
 *
 *    History :
 *    1. Date        : August 2, 2007
 *       Author      : Stanimir Bonev
 *       Description : Create
 *
 *  This example project shows how to use the IAR Embedded Workbench for ARM
 * to develop code for the Samsung-S3F4A0K evaluation board. It shows
 * basic use of Data flash.
 *  The example initialize data flash print contents in IO windows and then
 * change and print it again.
 *
 * Jumpers:
 *  All jumpers are in default position regarding board's manual
 *
 *    $Revision: 18083 $
 **************************************************************************/
#include <samsung\ios3f4a0k.h>
#include <stdio.h>
#include <string.h>
#include "arm_comm.h"
#include "board.h"


#pragma section="DATA_FLASH"
#pragma location="DATA_FLASH"
const char TestSting[] = {"IAR Systems\n"};

/*************************************************************************
 * Function Name: main
 * Parameters: none
 * Return: none
 *
 * Description: Main
 *
 *************************************************************************/
void main (void)
{
const char * Str = "Samsung automotive S3F4Axx series\n";
char * pDest = (char *)TestSting;
Int32U Tmp;
  // printing the initialized message
  printf(TestSting);
  // enable write in data flash
  Tmp = DFC_MR & 0xFFFF0060;
  DFC_MR = Tmp | (0x78 << 8);
  // erase page 0
  DFC_CSR = 0x7;  // clear status flags
  DFC_CR = (0x14 << 8) | (0x1 << 1);
  while(DFC_SR_bit.BUSY);
  if(DFC_SR_bit.DACCESS || !DFC_SR_bit.ENDERASE)
  {
    printf("Data flash erase error!!\n");
    return;
  }
  // write new message
  Int32U Count = strlen(Str) + 1;
  while(Count--)
  {
    DFC_CSR = 0x7;  // clear status flags
    *pDest++ = *Str++;
    while(DFC_SR_bit.BUSY);
    if(DFC_SR_bit.DACCESS || !DFC_SR_bit.ENDWR)
    {
      printf("Data flash write error!!\n");
      return;
    }
  }
  // printing the message
  printf(TestSting);
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?