请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:CC2650 工具/软件:TI-RTOS
你好
我有一个 HWI,它只使用 System_printf()和一个 Semaphore_post();Somehow,我得到了一个例外。 下面的图片中包含了有助于识别问题的代码。 没有意义的是、我将 HWI 缓冲区从768增加到4096、并且堆栈仍然会引发异常。 我不确定在任务上下文中如何分配 HWI 堆栈(在调用 HWI 时、HWI 堆栈是否会被使用)? 请注意、有一个外部.c 文件"CYC_counterR1.h"、其中包含一个包含约2Kb 数据和多个函数的算法。 这些函数暴露在 CC2650上运行的整个代码中、但这些函数仅从任务2 (CYC_算法)范围内调用。 执行其中一个函数时发生 HWI、是否会将大部分数据放在 HWI 堆栈上以供保留? 我的选项已经用完、找不到解决方案。 感谢您的帮助
/*
版权所有(c) 2015-2016、德州仪器(TI)公司
*保留所有权利。
*
*
只要
符合以下条件*、允许以源代码和二进制形式重新分发和使用:
*
*源代码的重新分发必须保留上述版权
声明*、此条件列表和以下免责声明。
*
***二进制形式的再发行必须在
*随发行提供的文档和/或其他材料中复制上述版权声明、本条件列表和以下免责声明。
*
***未经
事先书面许可、不得使用德州仪器公司的名称或*其贡献者的名称认可或推广从本软件衍生的产品*。
*
*本软件由版权所有者和贡献者"按原样"提供
*、
不承担任何明示或暗示的保证、包括但不限于*适销性和特定用途适用性的暗示保证*。 在任何情况下、版权所有者或
*贡献者都不对任何直接、间接、偶然、特殊、
*模范、 或相应的损害(包括但不限于
*采购替代产品或服务;丧失使用、数据或利润;
*或业务中断)、但出于任何责任理论
、*无论是在合同中、严格责任还是由于
使用本软件而以任何方式产生的侵权行为(包括疏忽或*其他)
、*即使已获悉可能会发生此类损坏。
//
/*
=== empty.c ======
//
//* XDCtools 头文件*/
#include
#include
#include
#include
#include
#include
/* BIOS 头文件*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "CYC_counterR1.h"
/* TI-RTOS 头文件*/
//#include
#include
//#include
#include
//#include
#include "scif.h"
#include "ex_include_tirtos.h"
#define BV (n) (1 <<(n))
//如果使用错误的操作系统设置
#ifndef SCIF_OSAL_TIRTOS_H 生成 SCIF 驱动程序,则显示错误消息
错误"SCIF 驱动程序在此示例中的操作系统配置不正确。 请在 Sensor Controller Studio 项目面板中更改为"TI-RTOS"、然后重新生成驱动程序。"
#endif
//如果使用错误的目标芯片封装
#ifndef SCIF_TARGET_CHICE_PACKAGE_QFN48_7X7_RGZ 生成 SCIF 驱动程序,则显示错误消息
错误"SCIF 驱动程序在本示例中具有不正确的目标芯片封装配置。 请在 Sensor Controller Studio 项目面板中更改为"QFN48 7x7 RGZ"、然后重新生成驱动程序。"
#endif
//电路板头文件*/
#include "Board.h"
#include "l_list.h"
//#define SERIALSTACK 2048
#define CYCSTACK 4096
#define LIDARSTACK 2048
char msg[64];//保持消息
char out[64];//保持输出消息
_Bool read_again = 0
;_bool
初始读数= 1;
_bool char _int = 1; //可以删除
long serial_time = 0;
long serial_dist = 0;
long serial_sensor = 0;
//
//通过串行读取/写入任务
//任务
_dar serial_task_Struct;//任务 serial_task_0[SERIALSTACK];任务_CYt alGO_Task_Struct];任务_Struct_Struct_char serial_task_task_结构;任务_task_task_task_cht_task_task_cht_task_task_cht_task_t_chtask_t_ch
char lidar_task_2[LIDARSTACK];
Semaphore_StructSemStruct;
Semaphore_Handle;
UART_Handle comm_handle;//堆句柄
UART_Params comm_params;//通信参数
HeapBuf_Params comm_params;
HeapBuf_handle memory_heap;
//堆处理 If_extern
;extern Error;堆处理组处理外部统计数据;处理外部
void HWI_ERROR()
{System_printf("HWI
error\n");
System_flush();
}
void scCtrlReadyCallback (vo){//
System_printf("rdycallback\n");
}// sclReadyCallback
void scTaskAlertCallback(vo){System_alertf("randcallback(n");//系统
调用()//系统调用 void //系统调用(wellwakeume);任务//系统调用 void
Semaphore_post (semHandle);
}// scTaskAlertCallback
void format_msg ()
{
static char * token = NULL;
token = strtok (msg、"、");//获取 time
serial_time = atol (token);//通过指针
标记存储时间= strtok (NULL、"、");//获取时间
串行标记= atol (token);//通过指针标记存储距离! //获取传感器
serial_sensor = atol (token);//通过指针
标记存储传感器= NULL;
}
void format_count_data ()
{
int size = sizeof (data_out)/sizeof (int);
static char longbubuy[15];
sprintf (longbuff、"%d"、time_out);
strcat (out、longbuff);//将时间转换为 char 数组、将其存储在 msg
strcat (out、"、")中;//添加一个逗号
静态 int k = 0;//用于迭代,仅为
(k=0;k)声明/创建一次 "%i",="" data_out[k]);="" strcat(out,="" longbuff);="" stores="" all="" data="" in="" char="" array="" if="" (k="" !="(size" -="" 1))="" ",");="" delimiter="" }="" k="0;" "!");="" final="" void="" lidar_task(uarg="" arg0,="" uarg="" arg1)="" types_freqhz="" fhz;="" timestamp_getfreq(&fhz);="" log_info0("testing");="" system_printf("timestamp="" freq:="" %d="" %d",="" fhz.hi,="" fhz.lo);="" system_flush();="" initialize="" the="" sensor="" controller="" scifosalinit();="" scifosalregisterctrlreadycallback(scctrlreadycallback);="" scifosalregistertaskalertcallback(sctaskalertcallback);="" scifinit(&scifdriversetup);="" set="" task="" tick="" interval="" to="" 1="" millisecond="" scifstartrtcticksnow(0x00010000);="" scifstartrtcticksnow(65);="" configure="" trigger="" interrupt="" at="" first="" result,="" and="" start="" controller's="" i2c="" light="" (not="" be="" confused="" with="" os="" tasks)="" scifstarttasksnbl(bv(scif_i2c_light_sensor_task_id));="" uint16_t="" status="scifTaskData.i2cLightSensor.state.i2cStatus;" (status!="0x00)" system_printf("i2c="" error!!!!\n");="" main="" loop="" while="" (1)="" wait="" for="" an="" alert="" callback="" system_printf("pending...\n");="" semaphore_pend(semhandle,="" bios_wait_forever);="" clear="" source="" scifclearalertintsource();="" uint32="" t="Clock_getTicks()/100;" system_printf("writing="" data\n");="" add_1(t,="" sciftaskdata.i2clightsensor.output.value[0]*10);="" add_2(t,="" sciftaskdata.i2clightsensor.output.value[1]*10);="" scifackalertevents();="" cyc_algo(uarg="" system_printf("cycalgo\n");="" *="" ***setup="" algorithm***="" applies="" initial="" toggle="0;" wl[toggle]="1;" system_printf("toggle\n");="" waits="" available="" while(!s1_rdy)="" system_printf("while1\n");="" rm_1(&py_time,="" &py_dist);="" appropriate="" variables="" dist_data[toggle][0]="dist_data[toggle][1];" buff_dist="current_dist" dist_data[toggle][1]="py_dist;" curr_dist="next" dist="" time_data[toggle][7]="time_data[toggle][4];" buffer_time="temp" time="" time_data[toggle][4]="py_time;" temp_time="new" system_printf("s1="" t,="" d:="" %d\n",="" py_time,="" py_dist);="" 2="" while(!s2_rdy)="" rm_2(&py_time,="" system_printf("s2="" (bool_cond[toggle][4])="" can="" shift="" =="0)" ?="" 1:0;="" (toggle="=" 0)="" while(!s1_rdy){="" ;="" log_write5(="" uiaevt_intwithkey,="" py_dist,="" 0,="" 0,(iarg)"py_dist");="" (py_dist"waiting="" s2\n");}="" bool_cond[toggle][4]="1;" sets="" multiplexer="" like="" functionality="" (wl[toggle]="=" 1)="" (while_loop1())="" system_printf("wl1\n");="" (output_ready)="" sends="" python="" format_count_data();="" uart_write(comm_handle,="" out,="" strlen(out));="" system_printf("output:="" %s\n",="" out);="" out[0]="\0" clear_output();="" output_ready="0;" has="" been="" written="" bios_exit(1);="" continue;="" 2)="" (while_loop2())="" 3)="" (while_loop3())="" read_write(uarg="" msg[0]="\0" initializes="" have="" no="" contents="" (very="" important!)="" *read_val;="" holds="" read="" value="" rdy[]="r!" ready="" string="" next[]="^d!" "done="" reading"="" system_printf("variables="" up\n");="" create="" a="" uart="" processing="" off.="" uart_params_init(&comm_params);="" comm_params.writedatamode="UART_DATA_BINARY;" comm_params.readdatamode="UART_DATA_BINARY;" comm_params.readreturnmode="UART_RETURN_FULL;" comm_params.readecho="UART_ECHO_OFF;" comm_params.baudrate="115200;" comm_handle="UART_open(Board_UART0," &comm_params);="" system_printf("comm="" set-up\n");="" int="" main(void)="" task_params="" serial_params;="" algo_params;="" lidar_params;="" semaphore_params="" semparams;="" call="" board="" init="" functions="" board_initgeneral();="" board_inituart();="" construct="" write="" thread="" task_params_init(&serial_params);="" serial_params.stacksize="SERIALSTACK;" serial_params.stack="&serial_task_0;" serial_params.priority="1;" task_construct(&serial_task_struct,="" (task_funcptr)read_write,="" &serial_params,="" null);="" lidar="" task_params_init(&lidar_params);="" lidar_params.stacksize="LIDARSTACK;" lidar_params.stack="&lidar_task_2;" lidar_params.priority="2;" task_construct(&lidar_task_struct,="" (task_funcptr)lidar_task,="" &lidar_params,="" test="" task_params_init(&algo_params);="" algo_params.stacksize="CYCSTACK;" algo_params.stack="&algo_task_1;" algo_params.priority="1;" task_construct(&algo_task_struct,="" (task_funcptr)cyc_algo,="" &algo_params,="" semaphore="" object="" use="" as="" resource="" lock,="" inital="" count="" semaphore_params_init(&semparams);="" semparams.mode="Semaphore_Mode_BINARY;" semaphore_construct(&semstruct,="" &semparams);="" obtain="" instance="" handle="" semhandle="Semaphore_handle(&semStruct);" declare="" define="" heap="" buf[2560];="" mau,="" cc2650="" this="" is="" bytes="" error_init(&eb);="" heapbuf_params_init(¶ms);="" params.blocksize="16;" 16="" maus="16" per="" block="" params.numblocks="160;" 160="" blocks="" (16="" bytes)="" params.buf="(Ptr)buf;" buffer="" character="" of="" params.bufsize="2560;" number="" contained="" within="" heap_buff="HeapBuf_create(¶ms," &eb);="" properties="" system_printf("starting="" bios\n");="" sysmin="" will="" only="" print="" console="" when="" you="" flush="" or="" exit="" init_sens_structs();="" bios="" bios_start();="" return="" (0);=""