S32K312 ITCM代码使用示例

编程入门 行业动态 更新时间:2024-10-22 21:29:57

S32K312 ITCM代码使用<a href=https://www.elefans.com/category/jswz/34/1770116.html style=示例"/>

S32K312 ITCM代码使用示例

        在上一篇文章中,介绍了S32K312 DTCM在代码中使用示例,具体可以参考配置文件的编辑,本文主要介绍ITCM的代码使用和调试。ITCM是将功能代码放到了高速缓存中,一方面频繁调用的函数可以快速访问,提高效率;另一方面比如操作S32K312的FLASH代码区的时候,可以实现擦除和写入。

        测试代码如下:

/* Including necessary configuration files. */
#include "Mcal.h"volatile int exit_code = 0;
/* User includes */void TestDelay(uint32 delay);
void __attribute__ ((section(".itcm0_code"))) Test_function_in_ITCM(void);void TestDelay(uint32 delay)
{static volatile uint32 DelayTimer = 0;while(DelayTimer<delay){DelayTimer++;}DelayTimer=0;
}void __attribute__ ((section(".itcm0_code"))) Test_function_in_ITCM(void)
{TestDelay(4800000);
}uint32_t __attribute__ ((section(".dtcm0_data"))) myDtcm0Data[1024] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
uint32_t __attribute__ ((section(".dtcm0_data"))) myDtcm0Data1[1024] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};void local_func(void)
{uint8_t tmp = 0;for(tmp = 0; tmp < 10; tmp++){(void)tmp;}
}/*!\brief The main function for the project.\details The startup initialization sequence is the following:* - startup asm routine* - main()
*/
int main(void)
{/* Write your code here */uint8 count = 0U;for(count = 0; count < 10; count++){Test_function_in_ITCM();local_func();myDtcm0Data[count] = myDtcm0Data1[count] + 10;}for(;;){if(exit_code != 0){break;}}return exit_code;
}

        验证Test_function_in_ITCM()这个方法,是运行在ITCM区中,debug查看函数方法的地址,

        方法的地址是0x00,与ITCM的地址范围匹配,

        再查看local_func()函数方法的地址,正常没有指定ITCM区的方法,函数地址应该在FLASH中

        local_func()函数地址在0x40166c的FLASH区中,满足在FLASH区中

        到此,就可以成功使用ITCM的功能了。

更多推荐

S32K312 ITCM代码使用示例

本文发布于:2023-11-17 12:53:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642977.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:示例   代码   ITCM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!