完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
开发板是s3c2440,nand flash型号是K9F2G08U0C,其中的头文件里面包含所有寄存器的地址
已经用点灯方式测试过每个函数都有运行过,反汇编文件里也显示0x30000000有main函数, 可是硬件上就是没有效果,能帮我的话,可以私信我一下 我把源码发给你 head.o函数: .text .global _start _start: ldrsp, = 4096 bldisable_watch_dog blmemsetup blnand_init ldr r0,=0x30000000 movr1,#4096 movr2,#1024 blnand_read ldrsp, =0x34000000 ldrlr, =halt_loop ldrpc,=main halt_loop: bhalt_loop nand.c函数: #include "s3c2440.h" #define BUSY 1 void nand_init(); void nand_read(unsigned char *buf, unsigned long start_addr, int size); static void s3c2440_nand_reset(void); static void s3c2440_wait_idle(void); static void s3c2440_nand_select_chip(void); static void s3c2440_nand_deselect_chip(void); static void s3c2440_write_cmd(int cmd); static void s3c2440_write_addr(unsigned int addr); static unsigned char s3c2440_read_data(void); static void s3c2440_nand_reset() { s3c2440_nand_select_chip(); s3c2440_write_cmd(0xff); s3c2440_wait_idle(); s3c2440_nand_deselect_chip(); } static void s3c2440_wait_idle() { int i; volatile unsigned char *p = (volatile unsigned char *)&NFSTAT; while (!(*p & BUSY)) for (i = 0; i < 10; i++); } static void s3c2440_nand_select_chip(void) { int i; NFCONT &= ~(1 << 1); for (i = 0; i < 10; i++); } static void s3c2440_nand_deselect_chip(void) { NFCONT |= (1 << 1); } static unsigned char s3c2440_read_data(void) { volatile unsigned char *p = (volatile unsigned char *)&NFDATA; return *p; } static void s3c2440_write_cmd(int cmd) { volatile unsigned char *p = (volatile unsigned char *)&NFCMD; *p = cmd; } #define NAND_SECTOR_SIZE_LP 4096 #define NAND_BLOCK_MASK_LP (NAND_SECTOR_SIZE_LP - 1) static void s3c2440_write_addr(unsigned int addr) { int i; volatile unsigned char *p = (volatile unsigned char *)&NFADDR; int col, page; col = addr & NAND_BLOCK_MASK_LP; page = addr / NAND_SECTOR_SIZE_LP; *p = col & 0xff;/* Column Address A0~A7 */ for(i=0; i<10; i++); *p = (col >> 8) & 0x0f; /* Column Address A8~A11 */ for(i=0; i<10; i++); *p = page & 0xff;/* Row Address A12~A19 */ for(i=0; i<10; i++); *p = (page >> 8) & 0xff;/* Row Address A20~A27 */ for(i=0; i<10; i++); *p = (page >> 16) & 0x01;/* Row Address A28~A29 */ for(i=0; i<10; i++); } void nand_init(void) { #define TACLS 0 #define TWRPH0 3 #define TWRPH1 0 /* 设置时序 */ NFCONF = (TACLS << 12) | (TWRPH0 << 8) | (TWRPH1 << 4); /* 使能NAND Flash控制器, 初始化ECC, 禁止片选 */ NFCONT = (1 << 4) | (1 << 1) | (1 << 0); s3c2440_nand_reset(); } #define NAND_SECTOR_SIZE 2048 #define NAND_BLOCK_MASK (NAND_SECTOR_SIZE - 1) void nand_read(unsigned char *buf, unsigned long start_addr, int size) { int i, j; if ((start_addr & NAND_BLOCK_MASK) || (size & NAND_BLOCK_MASK)) { return; /* 地址或长度不对齐 */ } /* 选中芯片 */ s3c2440_nand_select_chip(); for (i = start_addr; i < (start_addr + size);) { /* 发出READ0命令 */ s3c2440_write_cmd(0); /* Write Address */ s3c2440_write_addr(i); s3c2440_write_cmd(0x30); s3c2440_wait_idle(); for (j = 0; j < NAND_SECTOR_SIZE; j++, i++) { *buf = s3c2440_read_data(); buf++; } } /* 取消片选信号 */ s3c2440_nand_deselect_chip(); return; } |
|
相关推荐
5个回答
|
|
你用是MINI2440,还是QT2440学习板
|
|
|
|
TQ2440。我也有同样的问题。
|
|
|
|
楼主解决了没有 我也是同样的问题
|
|
|
|
没记错的话是这句 *p = (col >> 8) & 0x0f; /* Column Address A8~A11 */ 没有A8,A9开始。
|
|
|
|
*p = (col >> 8) & 0x0f; /* Column Address A8~A11 */
上楼的说的对,好像A8不用,用的是命令00h,01h区分,00表示0-255字节,01表示256-511字节,刚好就相当于A8地址线的作用 |
|
|
|
只有小组成员才能发言,加入小组>>
197个成员聚集在这个小组
加入小组为什么点亮LED的例子放在NORFlash上跑会出现奇怪的现象?
2177 浏览 6 评论
1982 浏览 5 评论
韦东山老师推出的《玩转ARM裸机实战》课程将帮你以上问题一扫而光!
4540 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-21 06:25 , Processed in 1.662852 second(s), Total 86, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号