本帖最后由 FSL_TICS_ZJJ 于 2014-10-21 14:41 编辑
大家如果在调试KL25第10版sample code代码的BME工程时,发现打印出的结果显示BME代码确没有普通C代码跑的快,请不要惊慌,本文教您如何解决!
由于第10版SC中BME.h 头文件写的比较冗余,不利于体现BME的优势,先将头文件做如下改写:
这里以BME_AND_W 函数为例。
原描写方式为:
_BME_INLINE void BME_AND_W (volatile uint32_t *addr, register uint32_t wdata)
{
*(volatile uint32_t*)((uint32_t)addr | BME_AND_MASK) = wdata;
}
现在修改为宏定义的方式:
#define BME_AND_W(addr, wdata) \
*(volatile uint32_t*)((uint32_t)addr | BME_AND_MASK) = wdata;
最终的打印结果显示为:
Running the LQRUG_bme_ex1 project.
systick start value: 0xFFFFF2
systick end value: 0xFFFFEE
systick current value read overhead: 0x4
systick start value: 0xFFFFD6
systick end value: 0xFFFFC2
actual execution cycle for logic operation with normal C code: 0x10
systick start value: 0xFFFFD7
systick end value: 0xFFFFC9
actual execution cycle for logic operation with BME macros: 0xA
systick start value: 0xFFFFE7
systick end value: 0xFFFFD3
actual execution cycle for BFI operation with normal C: 0x10
systick start value: 0xFFFFEE
systick end value: 0xFFFFE0
actual execution cycle for BFI operation with BME macro: 0xA
load_bit is 1
systick start value: 0xFFFFDF
systick end value: 0xFFFFCB
actual execution cycle for LAC1 operation with normal C: 0x10
load bit is 1
systick start value: 0xFFFFE4
systick end value: 0xFFFFD6
actual execution cycle for LAC1 operation with BME macro: 0xA
load_bit is 0
systick start value: 0xFFFFEA
systick end value: 0xFFFFD7
actual execution cycle for LAS1 operation with normal C: 0xF
load bit is 0
systick start value: 0xFFFFE3
systick end value: 0xFFFFD4
actual execution cycle for LAS1 operation with bme macro: 0xB
extracted data is 2
systick start value: 0xFFFFE9
systick end value: 0xFFFFD8
actual execution cycle for UBFX operation with normal C: 0xD
extracted data is 2
systick start value: 0xFFFFEF
systick end value: 0xFFFFE2
actual execution cycle for UBFX operation with bme macro: 0x9
结果体现了使用BME模块的优势。
附件为修改后的BME.h,需要的网友可以下载下来将代码包中的头文件直接替换即可。
BME.rar
(1.44 KB)
|