DSP中把某个函数接口放片上运行

#pragma CODE_SECTION 用法2012-9-27

         把某个运行慢的函数放到片上运行,提高速度。

前提:

使用工具CCS5.2C674x

 

使用说明:

The CODE_SECTION pragma allocates space for the symbol in C, or the next symbol declared in C++, in a section named section name.

The syntax of the pragma in C is:

#pragma CODE_SECTION (symbol, "section name")

The syntax of the pragma in C++ is:

#pragma CODE_SECTION ("section name")

 

举例:

 

test.cmd

SECTIONS

{

    /* DSP memory map */

    /* TI-ABI or COFF sections */

    /* EABI sections */

 

/*self definition */

.func           >   DSPL2RAM

 

}

 

main.c

#pragma CODE_SECTION(EFR_1, ".func")  //C中的写法

int EFR(const short *x, const short *wind)

{

    /*此函数操作*/

 

    return sum;

}

int EFR_1(const short *x, const short *wind)

{

    /*此函数操作*/

 

    return sum;

}

/*Main code 主程序*/

int main()

{

    EFR(xx, wind);       

EFR_1(xx, wind);

    return 0;

}

 

main.cpp

#pragma CODE_SECTION(".func")  //C++中的写法,.func为在.cmd//件自定义的段

int EFR(const short *x, const short *wind)

{

    /*此函数操作*/

 

    return sum;

}

int EFR_1(const short *x, const short *wind)

{

    /*此函数操作*/

 

    return sum;

}

/*Main code 主程序*/

int main()

{

    EFR(xx, wind);       

EFR_1(xx, wind);

    return 0;

}

 

可能会奇怪为什么没有指定那个函数呀?

使用说明中:” The CODE_SECTION pragma allocates space for the symbol in C, or the next symbol declared in C++, in a section named section name.这句话可以回答这个问题。在C++中为此声明的下一个符号声明分配空间。

 

注:

         本文代码不全不能运行,仅供参考。适用范围:实际中,如果经过优化后运行速度不够,可以考虑把某个影响速度的函数接口放到片上运行,#pragma CODE_SECTION来解决这个问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值