TMS320VC5509使用nof flash AM29LV400

阅读: 评论:0

TMS320VC5509使用nof flash AM29LV400

TMS320VC5509使用nof flash AM29LV400

1. 硬件接口如下,其中nor flash的使用方法,写的时候和NAND FLASH是一样的,读的时候和DRAM是一样的

2. 看下擦除指令和编程指令

3. 代码如下

#include <csl.h>
#include <csl_pll.h>
#include <csl_emif.h>
#include <csl_chip.h>
#include <stdio.h>
#include <csl_gpio.h>//#define AM29_FLASH_ADDR_BEGIN   (*((unsigned int *)0x200000))
#define AM29_FLASH_ADDR_BEGIN   ((unsigned int *)0x200000)
#define DATA_BUF_LEN 20
/*锁相环的设置*/
PLL_Config  myConfig      = {0,    //IAI: the PLL locks using the same process that was underway//before the idle mode was entered1,    //IOB: If the PLL indicates a break in the phase lock,//it switches to its bypass mode and restarts the PLL phase-locking//sequence6,    //PLL multiply value; multiply 12 times12             //Divide by 2 PLL divide value; it can be either PLL divide value//(when PLL is enabled), or Bypass-mode divide value//(PLL in bypass mode, if PLL multiply value is set to 1)
};
/*SDRAM的EMIF设置*/
EMIF_Config emiffig = {0x221,     //EGCR  : the MEMFREQ = 00,the clock for the memory is equal to cpu frequence//          the WPE = 0 ,forbiden the writing posting when we debug the EMIF//        the MEMCEN = 1,the memory clock is reflected on the CLKMEM pin//        the NOHOLD = 1,HOLD requests are not recognized by the EMIF0xFFFF,    //EMI_RST: any write to this register resets the EMIF state machine0x3FFF,    //CE0_1:  CE0 space control register 1//        MTYPE = 011,Synchronous DRAM(SDRAM),16-bit data bus width0xFFFF,   //CE0_2:  CE0 space control register 20x00FF,   //CE0_3:  CE0 space control register 3//        TIMEOUT = 0xFF;0x1FFF,    //CE1_1:  CE0 space control register 1//        Asynchronous, 16Bit0xFFFF,    //CE1_2:  CE0 space control register 20x00FF,    //CE1_3:  CE0 space control register 30x1FFF,    //CE2_1:  CE0 space control register 1//        Asynchronous, 16Bit0xFFFF,    //CE2_2:  CE0 space control register 20x00FF,    //CE2_3:  CE0 space control register 30x1FFF,    //CE3_1:  CE0 space control register 10xFFFF,    //CE3_2:  CE0 space control register 20x00FF,    //CE3_3:  CE0 space control register 30x2911,   //SDC1:   SDRAM control register 1//          TRC = 8//        SDSIZE = 0;SDWID = 0//        RFEN = 1//        TRCD = 2//        TRP  = 20x0410,    //SDPER : SDRAM period register//          7ns *40960x07FF,    //SDINIT: SDRAM initialization register//        any write to this register to init the all CE spaces,//        do it after hardware reset or power up the C55x device0x0131    //SDC2:      SDRAM control register 2//        SDACC = 0;//        TMRD = 01;//        TRAS = 0101;//        TACTV2ACTV = 0001;
  };
void  delay(unsigned int d_time)
{unsigned int loop = 0;while(d_time--){loop = 1000;while(loop--);}
}Uint16    ChipErase(void)
{Uint16    i,Data;Uint32    TimeOut;*(AM29_FLASH_ADDR_BEGIN + 0x555) = 0xAA;*(AM29_FLASH_ADDR_BEGIN + 0x2AA) = 0x55;*(AM29_FLASH_ADDR_BEGIN + 0x555) = 0x80;*(AM29_FLASH_ADDR_BEGIN + 0x555) = 0xAA;*(AM29_FLASH_ADDR_BEGIN + 0x2AA) = 0x55;*(AM29_FLASH_ADDR_BEGIN + 0x555) = 0x10;i = 0;TimeOut = 0;delay(8000);while(i<5){Data = *(AM29_FLASH_ADDR_BEGIN +  0x1FF);if    (Data == 0xFFFF)    i++;else    i=0;if ( ++TimeOut>0x1000000)    return (0);}for    (i=0;i<0x400;i++){Data = *(AM29_FLASH_ADDR_BEGIN + i);if (Data !=0xFFFF)    return (0);}return  (1);}Uint16    FlashWrite(Uint32    RomStart, Uint16*   buf_start,  Uint16    Length)
{Uint32    i,TimeOut;Uint16    Data1,Data2,j;for    (i=0;i<Length;i++){*(AM29_FLASH_ADDR_BEGIN + 0x555)= 0xAA;*(AM29_FLASH_ADDR_BEGIN + 0x2AA)= 0x55;*(AM29_FLASH_ADDR_BEGIN + 0x555) = 0xA0;*(AM29_FLASH_ADDR_BEGIN + RomStart + i) = *(buf_start++);TimeOut = 0;j=0;delay(10);}while(j<5){Data1 = *(AM29_FLASH_ADDR_BEGIN + RomStart + i);Data2 = *(AM29_FLASH_ADDR_BEGIN + RomStart + i);if    (Data1 == Data2)    j++;else    j=0;if ( ++TimeOut>0x1000000)    return (0);}return  (1);
}void    FlashRead(Uint32    RomStart, Uint16*   buf_start,    Uint16    Length){Uint32    i;for    (i=0;i<Length;i++){*(buf_start++) =  (*((volatile    unsigned  int  *)(AM29_FLASH_ADDR_BEGIN + RomStart + i)));}}main()
{Uint16 data_buf[DATA_BUF_LEN] = {0};unsigned int i = 0;Uint16 write_buf[DATA_BUF_LEN] = {0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,0x0008,0x0009,0x0000,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017,0x0018,0x0019,0x0010};unsigned int test_data = 0;/*初始化CSL库*/CSL_init();/*EMIF为全EMIF接口*/CHIP_RSET(XBSR,0x0a01);/*设置系统的运行速度为144MHz*/PLL_config(&myConfig);/*初始化DSP的EMIF*/EMIF_config(&emiffig);/*确定方向为输出*/GPIO_RSET(IODIR,0xFF);GPIO_RSET(IODATA,0x00);ChipErase();FlashWrite(0, write_buf,  DATA_BUF_LEN);delay(1000);FlashRead(0, data_buf,  DATA_BUF_LEN);for(i=0;i<DATA_BUF_LEN;i++){if(write_buf[i] != data_buf[i]){printf("test data error:%d",i);}}if(i == DATA_BUF_LEN){printf("test data ok");}for(;;);
}

 

转载于:.html

本文发布于:2024-01-29 03:30:21,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170647022812396.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:nof   flash
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23