为了账号安全,请及时绑定邮箱和手机立即绑定

原理代码求注释,帮帮忙啊!

原理代码求注释,帮帮忙啊!

婷婷同学_ 2022-10-02 14:10:48
* File: main.c* Author: WuhanR&Dembest* Desc: cmain entry* History:/* includes files*/#include"2410lib.h"/********************************************************************************************** name: main* func: c code entry* para: none* ret: none* modify:* comment:*********************************************************************************************/void main(intargc,char **argv){sys_init(); /* Initials3c2410's Clock, MMU, Interrupt,Port and UART */memory_test();while(1){};}/****************************************************/* File: memory.c* Author: WuhanR&D Center, embest* Desc: memorytest file* History:*****************************************************/#include"def.h"#include"option.h"void memory_test(void){int i;UINT32T data;int memError=0;UINT32T *pt;// memory testuart_printf("\nMemoryTest(%xh-%xh):WR\n", _RAM_STARTADDRESS+0xe00000,(_ISR_STARTADDRESS&0xf0ff0000));//memory writept=(UINT32T*)(_RAM_STARTADDRESS+0xe00000);while((UINT32T)pt<(_ISR_STARTADDRESS&0xf0ff0000)){*pt=(UINT32T)pt;pt++;}//MEMORY READuart_printf("MemoryTest(%xh-%xh):RD\n", _RAM_STARTADDRESS+0xe00000,(_ISR_STARTADDRESS&0x0f0ff0000));//uart_printf("\b\bRD");pt=(UINT32T*)(_RAM_STARTADDRESS+0xe00000);while((UINT32T)pt<(_ISR_STARTADDRESS&0xf0ff0000)){data=*pt;if(data!=(UINT32T)pt){memError=1;uart_printf("\b\bFAIL:0x%x=0x%x\n",i,data);break;}pt++;}if(memError==0)uart_printf("\n\b\bO.K.\n");}尽量多的注释,非常急
查看完整描述

1 回答

?
青春有我

TA贡献1784条经验 获得超8个赞

void memory_test(void)
{
int i;
UINT32T data;
int memError=0;
UINT32T *pt;
// memory test
uart_printf("\nMemoryTest(%xh-%xh):WR\n", _RAM_STARTADDRESS+0xe00000,
(_ISR_STARTADDRESS&0xf0ff0000)); /*打印出内存测试函数所覆盖地址1-地址2的范围*/
//memory write
pt=(UINT32T*)(_RAM_STARTADDRESS+0xe00000);/*指针pt指向地址1*/
while((UINT32T)pt<(_ISR_STARTADDRESS&0xf0ff0000))
{
/*向内存地址中不断写入其地址值的内容
假设现在地址是0x2000 1000这个地方写上一个叫做0x2000 1000的值
再在地址是0x2000 1004这个地方写上一个叫做0x2000 1004的值
以此类推

*/
*pt=(UINT32T)pt;
pt++;
}/*全部写完*/
//MEMORY READ
uart_printf("MemoryTest(%xh-%xh):RD\n", _RAM_STARTADDRESS+0xe00000,
(_ISR_STARTADDRESS&0x0f0ff0000));/*打印出需要读取内容的地址范围,地址1-地址2*/
//uart_printf("\b\bRD");
pt=(UINT32T*)(_RAM_STARTADDRESS+0xe00000);/*用指针pt指向地址1*/
/*将地址1-地址2的内容依次以32位取出*/
while((UINT32T)pt<(_ISR_STARTADDRESS&0xf0ff0000))
{data=*pt;/*取出pt指针所指向地址的内容*/
if(data!=(UINT32T)pt)/*判断该内容是否为其地址值*/
{memError=1;
uart_printf("\b\bFAIL:0x%x=0x%x\n",i,data);/*不等,则测试失败*/
break;}
pt++;}
if(memError==0)
uart_printf("\n\b\bO.K.\n");}/*地址1-地址2中的内容全为其地址值,测试成功*/


查看完整回答
反对 回复 2022-10-06
  • 1 回答
  • 0 关注
  • 128 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号