网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> DSP >> 代码示例 >> TI DSP代码示例 >> C6000 >> 文章正文
  CCS下对C6416开发板EPROM的烧写程序         ★★★ 【字体:
CCS下对C6416开发板EPROM的烧写程序
作者:61IC    文章来源:本站原创    点击数:    更新时间:2007-1-23    

/********************************************************************************/
/* flashcode.c         */
/* Written by: Kyle Castille       */
/* Updated by: Michael Haag (6/27/01)      */                                               
/* This program will create a dummy data buffer with an incrementing count */
/* in internal memory, and then program this data to the AM29LV800-90 Flash */
/* which is a 1M x 8/512k x 16, 90 ns Flash memory.    */
/*           */
/* This program assumes that the ARDY interface is used, so no software  */
/* checking is done to detect end of operation for erase or program  */
/*          */
/********************************************************************************/
#define CHIP_6416 1

#define  CE1_ADDRS 0x64000000
#define  INT_MEM  0x00000000
#define  FLASH_ADDRS  CE1_ADDRS
#define  SRC_ADDRS  INT_MEM
#define  LENGTH   0x400
#define  TRUE   1
#define  FALSE   0
#include <stdlib.h>
#include <stdio.h>
#include <csl.h>
#include <csl_emifb.h>
#include <csl_emifbhal.h>
extern EMIFB_Config config;
void load_source (short * source, int num_words);
void erase_flash(int * flash_addrs);
void program_flash(short * source, int * flash_addrs, int num_words);

 

/****************************************************************************/
/* emif_config :Routine to configure the Emif for operation with    */
/*  AM29LV800-90 at CE1.  This routine sets the CE1 control register */
/*  for a 32 bit asynchronous memory interface with the following   */
/*  parameters:        */
/*  Mtype = 010 (32-bit async memory)     */
/*  Read Setup/Strobe/Hold = 1/21/3      */
/*  Write Setup/Strobe/Hold = 2/13/3     */
/*           */
/****************************************************************************/


void
main(){
 int * flash_ptr = (int *)FLASH_ADDRS;
 short * src_ptr = (short *)SRC_ADDRS;

 /* initialize the CSL library */
   CSL_init();

 EMIFB_config(&config);
 load_source(src_ptr, LENGTH);
 erase_flash(flash_ptr);
 program_flash(src_ptr, flash_ptr, LENGTH);
 printf("Successful erase and program!!!");
}

/****************************************************************************/
/* load_source : Routine to load the source memory with data.  This routine */
/*  loads an incrementing count into the source memory for   */
/*  demonstration purposes.           */
/* Inputs:         */
/* source_ptr :  Address to be used as the source buffer  */
/* length    :  Length to be programmed    */
/*          */
/****************************************************************************/


EMIFB_Config config = {
 /* Create Global Control Register field */
0x00002060,
0x02a08a00,
0x02a08a00,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
};

void load_source(short * source_ptr, int length)
{
 int i;

 for (i = 0; i < length; i ++){
  * source_ptr++ = i;
 }
}

/****************************************************************************/
/* erase_flash : Routine to erase entire FLASH memory AM29LV800 (1M x 8bit/ */
/*  512k x 16bit)       */
/* Inputs:         */
/* flash_ptr: Address of the FLASH PEROM               */
/*           */
/****************************************************************************/
 
void erase_flash(int * flash_ptr)
{
 /* Control addresses are left shifted so that   */
 /*  they appear correctly on the EMIF's EA[19:2] */
 /* Byte address << 2 == Word Address    */

 int * ctrl_addr1 = (int *) ((int)flash_ptr + (0x555 << 2));
 int * ctrl_addr2 = (int *) ((int)flash_ptr + (0x2aa << 2));;

 * ctrl_addr1 = 0x00aa; /* Erase sequence writes to addr1 and addr2  */
 * ctrl_addr2 = 0x0055; /*  with this data         */
 * ctrl_addr1 = 0x0080;
 * ctrl_addr1 = 0x00aa;
 * ctrl_addr2 = 0x0055;
 * ctrl_addr1 = 0x0010;
}

/****************************************************************************/
/* program_flash: Routine to program FLASH AM29LV800    */
/* Inputs:         */
/* flash_ptr : Address of the FLASH      */
/* source_ptr : Address of the array containing the code to program  */
/*  length  : Length to be programmed    */
/*          */
/****************************************************************************/

void program_flash(short * source_ptr, int * flash_ptr, int length)
{
 int i;

 /* Control addresses are left shifted so that    */
 /*  they appear correctly on the EMIF's EA[19:2] */
 /* Byte address << 2 == Word Address       */
 int * ctrl_addr1 = (int *) ((int)flash_ptr + (0x555 << 2));
 int * ctrl_addr2 = (int *) ((int)flash_ptr + (0x2aa << 2));;
  
 for (i = 0; i < length; i++){

  * ctrl_addr1 = 0x00aa;
  * ctrl_addr2 = 0x0055;
  * ctrl_addr1 = 0x00a0;

  * flash_ptr++ = * source_ptr++;
 }
}

 

               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    采用DSP 免提开发平台的车载…
    H.264编解码器在C6416 DSP上…
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号