nand_flash_v3.zip

  • haobin
    了解作者
  • C/C++
    开发工具
  • 54KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-03-16 22:24
    上传日期
s3c2440 nand flash操作示例代码,包括读,写操作。
nand_flash_v3.zip
  • __Previews
  • uart.hPreview
    7.8KB
  • norflash.o
    5.6KB
  • nandflash.o
    5.7KB
  • uart.h
    197B
  • main.o
    900B
  • uart.c
    2.5KB
  • uart.o
    3.5KB
  • s3c24xx.h
    9.5KB
  • test.c
    249B
  • start.o
    1.8KB
  • timer.c
    704B
  • led.h
    75B
  • start.S
    3KB
  • und.o
    788B
  • sdram.o
    1KB
  • led.o
    699B
  • sdram.c
    485B
  • main.dis
    110.4KB
  • key_int.c
    1.5KB
  • Makefile
    454B
  • main.elf
    45.9KB
  • led.c
    224B
  • test.o
    1.1KB
  • timer.h
    95B
  • key_int.o
    2KB
  • main.bin
    10.1KB
  • norflash.c
    4.6KB
  • nandflash.c
    5.7KB
  • und.c
    65B
  • timer.o
    1.4KB
  • sdram.h
    129B
  • sdram.lds
    263B
  • key_int.h
    122B
  • main.c
    278B
内容介绍
#include "s3c24xx.h" void ce_enable(void) { NFCONT &= ~(1<<1); //使能片选 } void ce_disable(void) { NFCONT |= (1<<1); //禁止片选 } void nand_wait_ready(){ while(!(NFSTAT & (1<<0))); } void nand_write_commnd(unsigned char cmd){ nand_wait_ready(); NFCMD = cmd; //写命令 } void nand_write_addr(unsigned char addr){ nand_wait_ready(); NFADDR = addr; //写地址 } unsigned char nand_read(void){ nand_wait_ready(); return NFDATA; } void nand_write_data(unsigned char data){ nand_wait_ready(); NFDATA = data; } void nand_init(void){ #define TACLS 0 #define TWRPH0 1 #define TWRPH1 0 NFCONF = (TACLS<<12) | (TWRPH0<<8) | (TWRPH1<<4); NFCONT = (1<<4) | (1<<1) | (1<<0); } void do_nand_read(void){ int i = 0; int j = 0; unsigned int addr; unsigned char buf[100]; unsigned int len; puts("please enter the addr: "); puts("\n\r"); addr =(int) getint(); puts("\n\r"); puts("please enter the len: "); puts("\n\r"); len =(int) getint(); puts("\n\r"); ce_enable(); //使能片选 int page = addr/2048; int col = addr & (2048-1); while (i < len) { nand_write_commnd(0x00); nand_write_addr(col & 0xff); //发生低八位列地址 nand_write_addr((col>>8) & 0xff); //高八位 nand_write_addr(page & 0xff); //发生低八位行地址 nand_write_addr((page>>8) & 0xff); //高八位 nand_write_addr((page>>16) & 0xff); //最高八位 nand_write_commnd(0x30); nand_wait_ready(); for(;(col < 2048) && (i < len); col++){ buf[i] = nand_read(); printtwo(buf[i]); puts(" "); i++; } puts(" ; "); for(j=0; j<=i; j++){ if(buf[j] < 0x20 || buf[j] > 0x7e) putchar('.'); else putchar(buf[j]); } if(i == len) break; col = 0; page++; } ce_disable(); //操作完,禁止片选 } void do_nand_init(unsigned int addr,unsigned char* buf,unsigned int len){ int i = 0; ce_enable(); //使能片选 int page = addr/2048; int col = addr & (2048-1); while (i < len) { nand_write_commnd(0x00); nand_write_addr(col & 0xff); //发生低八位列地址 nand_write_addr((col>>8) & 0xff); //高八位 nand_write_addr(page & 0xff); //发生低八位行地址 nand_write_addr((page>>8) & 0xff); //高八位 nand_write_addr((page>>16) & 0xff); //最高八位 nand_write_commnd(0x30); nand_wait_ready(); for(;(col < 2048) && (i < len); col++){ buf[i] = nand_read(); i++; } if(i == len) break; col = 0; page++; } ce_disable(); //操作完,禁止片选 } void nand_chip_id(void){ unsigned char buf[5]; int i; ce_enable(); //使能片选 nand_write_commnd(0x90); nand_write_addr(0x00); for(i=0; i<5; i++){ buf[i] = nand_read(); printtwo(buf[i]); puts("\n\r"); } ce_disable(); //操作完,禁止片选 } void do_nand_erase(){ unsigned int addr; puts("\n\r"); puts("please enter erase addr: "); addr =(unsigned int) getint(); puts("\n\r"); ce_enable(); //使能片选 int page = addr/2048; nand_write_commnd(0x60); nand_write_addr(page & 0xff); //发生低八位行地址 nand_write_addr((page>>8) & 0xff); //高八位 nand_write_addr((page>>16) & 0xff); //最高八位 nand_write_commnd(0xD0); nand_wait_ready(); ce_disable(); } void do_nand_write(){ int i = 0; unsigned int len; unsigned int addr; unsigned char str[100]; puts("please enter write addr: "); addr = getint(); puts("\n\r"); puts("please enter write data: "); gets(str); puts("\n\r"); puts("please enter write len: "); len = getint(); puts("\n\r"); ce_enable(); //使能片选 int page = addr/2048; int col = addr & (2048-1); while(i < len){ nand_write_commnd(0x80); nand_write_addr(col & 0xff); //发生低八位列地址 nand_write_addr((col>>8) & 0xff); //高八位 nand_write_addr(page & 0xff); //发生低八位行地址 nand_write_addr((page>>8) & 0xff); //高八位 nand_write_addr((page>>16) & 0xff); //最高八位 for(; (col<2048) && (i<len); col++){ nand_write_data(str[i]); i++; } nand_write_commnd(0x10); //内部烧写 nand_wait_ready(); if(i == len) break; col = 0; page ++; } ce_disable(); } void nand_flash_test(void){ char c; while(1){ puts("\n\r"); puts("[s] scan nand flash\n\r"); puts("[e] erase nand flash\n\r"); puts("[w] write nand flash\n\r"); puts("[r] read nand flash\n\r"); puts("[q] quit \n\r"); puts("please choose a selection"); puts("\n\r"); c = getchar(); puts("\n\r"); putchar(c); puts("\n\r"); switch(c){ case 'q': case 'Q': return; break; case 's': case 'S': nand_chip_id(); break; case 'e': case 'E': do_nand_erase(); break; case 'w': case 'W': do_nand_write(); break; case 'r': case 'R': do_nand_read(); break; default: break; } } }
评论
    相关推荐
    • s3c2440-nand-flash-256M-nand.rar
      s3c2440nandflash 操作源代码 开发环境ADS1.2
    • s3c2440a_6NandFlash.rar
      S3C2440A中文开发手册,第六单元,NANDFLASH使用
    • s3c2440nand.zip
      自己写的基础s3c2440的mini2440nand flash驱动,经过测试,完全可以用
    • s3c2440A中文资料
      s3c2440a_6NandFlash s3c2440a_7clock&power; s3c2440a_8DMA s3c2440a_10PWM&Timer; s3c2440a_11UART s3c2440a_14INTCtrl s3c2440a_16ADC&TSC; s3c2440a_17RTC s3c2440a_18WTD s3c2440a_19SDIO s3c2440a_20IIC s3c...
    • s3c6410_NANDFLASH源代码
      s3c6410_NANDFLASH源代码 s3c6410_NANDFLASH源代码 s3c6410_NANDFLASH源代码
    • MINI2440 QQ2440 NAND FLASH
      MINI2440 QQ2440 NAND FLASHh代码程序 由韦东山教程改写 友善之臂QQ2440V3测试 MINI2440通用
    • S3C2440 NandFlash操作例程
      S3C2440 NandFlash操作例程
    • s3c2440芯片中文手册
      s3c2440a_6NandFlash.pdf s3c2440a_7clock&power;(时钟电源).pdf s3c2440a_8DMA.pdf s3c2440a_10PWM&Timer;.pdf s3c2440a_11UART (串口).pdf s3c2440a_14INTCtrl(中断控制).pdf s3c2440a_15LCD控制器中文手册.pdf ...
    • S3C2440裸奔---Nandflash源代码
      首先需要搭建一个可以编译代码的环境。从一开始我就不想用ADS(安装完ADS后会产生一个CodeWarrior for ARM Developer Suite的工具,可以编译和调试代码),虽然它是个很好的工具,但是它却隐藏了很多的细节,不利于...
    • S3C2440A 裸奔之nandflash操作
      S3C2440A 裸奔之nandflash操作,读写已验证