完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
本帖最后由 一只耳朵怪 于 2018-6-13 16:52 编辑
我在F28027的FOC例程lab_2b中看到这样的语句: #ifdef FLASH memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart); #endif 这个应该就是把代码从ROM中复制到RAM中的语句,但是我奇怪的是,为什么在网上搜到的一些关于C20x系列芯片的资料里memCopy函数的后面还有一个InitFlash函数? 这里为什么不需要? |
|
相关推荐
10个回答
|
|
|
|
|
|
|
|
|
看了一下memCopy.c文件,未见封装到memCopy中。 c文件的定义: // ************************************************************************** // the functions void memCopy(uint16_t *srcStartAddr,uint16_t *srcEndAddr,uint16_t *dstAddr) [ while(srcStartAddr <= srcEndAddr) [ *dstAddr++ = *srcStartAddr++; ] return; ] // end of memCopy() function // end of file 这就奇怪了。再往后面的程序的函数,不能把InitFlash函数封装进去呀~? |
|
|
|
|
cmh16 发表于 2018-6-13 06:42 少打一个字: 再往后面的程序的函数,不可能把InitFlash函数封装进去呀~? |
|
|
|
|
|
在这个lab_02b工程中,相关的代码已经被封装到FLASH_setup了,但是没有被调用。 查了一下资料,似乎InitFlash()函数并不是必须的,它只是优化Flash中程序的运行。 我这个理解对么? |
|
|
|
|
cmh16 发表于 2018-6-13 07:08 你的理解不对,如果要在FLASH里跑程序就必须初始化FLAHS, EALLOW; //Enable Flash Pipeline mode to improve performance //of code executed from Flash. FlashRegs.FOPT.bit.ENPIPE = 1; // CAUTION //Minimum waitstates required for the flash operating //at a given CPU rate must be characterized by TI. //Refer to the datasheet for the latest information. //Set the Paged Waitstate for the Flash FlashRegs.FBANKWAIT.bit.PAGEWAIT = 3; //Set the Random Waitstate for the Flash FlashRegs.FBANKWAIT.bit.RANDWAIT = 3; //Set the Waitstate for the OTP FlashRegs.FOTPWAIT.bit.OTPWAIT = 5; // CAUTION //ONLY THE DEFAULT VALUE FOR THESE 2 REGISTERS SHOULD BE USED FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF; FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF; EDIS; 这是InitFlash的代码,其中有优化也有配置,例如PAGEWAIT和RANDWAIT,就是必须配置的,否则程序都不能运行。因为他们决定了Flash告诉运行时的等待时间。 |
|
|
|
|
muuwfwr 发表于 2018-6-13 07:25 但是我在instaSPIN-FOC的lab04中根本找不到InitFlash函数,倒是在flash.c中有如下的定义: #pragma CODE_SECTION(FLASH_setup, "ramfuncs"); void FLASH_setup(FLASH_Handle flashHandle) [ //Enable Flash Pipeline mode to improve performance //of code executed from Flash. FLASH_enablePipelineMode(flashHandle); // FlashRegs.FOPT.bit.ENPIPE = 1; // CAUTION //Minimum waitstates required for the flash operating //at a given CPU rate must be characterized by TI. //Refer to the datasheet for the latest information. #if (CPU_FRQ_50MHZ) //Set the Paged Waitstate for the Flash FLASH_setNumPagedReadWaitStates(flashHandle, FLASH_NumPagedWaitStates_2); // FlashRegs.FBANKWAIT.bit.PAGEWAIT = 2; //Set the Random Waitstate for the Flash FLASH_setNumRandomReadWaitStates(flashHandle, FLASH_NumRandomWaitStates_2); // FlashRegs.FBANKWAIT.bit.RANDWAIT = 2; //Set the Waitstate for the OTP FLASH_setOtpWaitStates(flashHandle, FLASH_NumOtpWaitStates_2); // FlashRegs.FOTPWAIT.bit.OTPWAIT = 2; #elif (CPU_FRQ_40MHZ) //Set the Paged Waitstate for the Flash FLASH_setNumPagedReadWaitStates(flashHandle, FLASH_NumPagedWaitStates_1); // FlashRegs.FBANKWAIT.bit.PAGEWAIT = 1; //Set the Random Waitstate for the Flash FLASH_setNumRandomReadWaitStates(flashHandle, FLASH_NumRandomWaitStates_1); // FlashRegs.FBANKWAIT.bit.RANDWAIT = 1; //Set the Waitstate for the OTP FLASH_setOtpWaitStates(flashHandle, FLASH_NumOtpWaitStates_1); // FlashRegs.FOTPWAIT.bit.OTPWAIT = 1; #endif // CAUTION //ONLY THE DEFAULT VALUE FOR THESE 2 REGISTERS SHOULD BE USED // FlashRegs.FSTDBYWAIT.bit.STDBYWAIT = 0x01FF; FLASH_setStandbyWaitCount(flashHandle, 0x01FF); // FlashRegs.FACTIVEWAIT.bit.ACTIVEWAIT = 0x01FF; FLASH_setActiveWaitCount(flashHandle, 0x01FF); //Force a pipeline flush to ensure that the write to //the last register configured occurs before returning. asm(" RPT #7 || NOP"); ] 但是这个函数在这个工程中,根本没有被调用(即使把这个函数的定义删掉,也能正常生成out文件,并能运行)。 这个讲不通呀!? |
|
|
|
|
muuwfwr 发表于 2018-6-13 07:25 我找到设置的地方了 main()——>HAL_setParams——> HAL_setupFlash()里有: FLASH_enablePipelineMode(obj->flashHandle); FLASH_setNumPagedReadWaitStates(obj->flashHandle,FLASH_NumPagedWaitStates_2); FLASH_setNumRandomReadWaitStates(obj->flashHandle,FLASH_NumRandomWaitStates_2); FLASH_setOtpWaitStates(obj->flashHandle,FLASH_NumOtpWaitStates_3); FLASH_setStandbyWaitCount(obj->flashHandle,FLASH_STANDBY_WAIT_COUNT_DEFAULT); FLASH_setActiveWaitCount(obj->flashHandle,FLASH_ACTIVE_WAIT_COUNT_DEFAULT); return; 但是,从程序上看,此时设置Flash,已经离开始进入main()函数有一段时间,这个过程中,已经执行了很多语句了。 此时才设置,是不是可以认为:这些Flash优化的设置不是绝对必须的? 要不之前执行了那么多代码,就不对了~ |
|
|
|
|
cmh16 发表于 2018-6-13 08:01 如果不执行FLASH初始化,会在长时间运行后出现问题,比如等待时间的设置就会导致读出错误的数据,所以必须在初始化的代码中加入。 |
|
|
|
|
|
追问一下,要是在Debug模式下,所有的指令和数据等都直接下载到RAM中运行的话,是不是就不需要InitFlash()了? |
|
|
|
|
|
另外,是不是只要在Flash中运行程序或使用了Flash中的数据,就要使用InitFlash()函数? |
|
|
|
|
只有小组成员才能发言,加入小组>>
549 浏览 0 评论
1613 浏览 0 评论
2047 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1513 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1337 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1757浏览 29评论
2781浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1724浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1634浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1645浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 07:39 , Processed in 0.842051 second(s), Total 91, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
3317