初始化变量
uint32_t * DWT_CONTROL=(uint32_t *)0xE0001000;
uint32_t * DWT_CYCCNT=(uint32_t *)0xE0001004;
uint32_t * DEMCR=(uint32_t *)0xE000EDFC;
volatile uint32_t vtpai_process_start=0;
volatile uint32_t vtpai_process_end=0;
volatile uint32_t vtpai_process_over=0;
设置 DWT模块
* DEMCR= * DEMCR | 0x01000000;
* DWT_CYCCNT=0;
* DWT_CONTROL = * DWT_CONTROL | 1;
使用 DWT模块 得到函数运行周期
vtpai_process_start=*DWT_CYCCNT;
ret = VTAPI_process(vtapi, voice_cache[m], &numDetection, detections);
vtpai_process_end=*DWT_CYCCNT;
printf("vtpai_process_count is %d\n",vtpai_process_end -vtpai_process_start );
根据得到的周期除以 运行频率可以得到执行这个函数需要多长时间