This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
工具/软件:TI-RTOS
尊敬的 TI 专家:
我目前正在将代码从 CC2640移植到 CC2642R1上运行的新器件、并遇到一些与堆相关的问题。
在 CC2640构建中、在.cfg 文件中将堆大小定义为"BIOS.heapSize = 512*5"、并使用了以下代码:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // num_sequence 计算: // // [(BIOS_heap_size - 20)/2 ] // ---------------------- // sd_sequence_size //其中: // BIOS_heap_size -系统默认堆的大小(以字节为单位 )// 在 settings.h //中定义 它是对在.cfg 中定义的 BIOS.heapSize 的手动引用// //// 注意:未找到从.cfg 文件中读取此变量 的方法// #include 已包含在 settings.h 中、以实现 // 此功能、但未成功集成。 // 因此、必须手动检查 BIOS.heapSize 并将其分配给 // settings.h 中的 BIOS_heap_size // (使用 HeapMem 模块-在中进行了详细描述: // SYS/BIOS (TI-RTOS 内核) v6.46.01用户指南第7章) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define NUM_SEQUENCE (((((BIOS_heap_size)- 28)/2)/(SD_sequence_size))//以字节 #define buffer_size 为单位 ((((sd_seque_size)*(NUM_sequence))) //以字节为单位 //对于每个缓冲区写入 #define AFE_ELEMENTS (AFE4404_SAMPLE_RAM/ADXL345_SAMPLE_RATE)*(SAMPLE_INFARED+SAMPLE_RED+SAMPLE_GREEN) static int TIMESTAMP_START; static int TIMESTAMP_END; long long int TIMESTAMP=999; typedef struct SDBuffer{ bool 地址; //选择两个分配的缓冲区 SD_ADDRESSES 中的一个的值,即 sdbuffer 或 tempsdcbuffer Int Size; //为每个缓冲区分配的内存大小 int 索引; //值以跟踪正在访问的内存元素并指示何时访问 //缓冲区已满 bool 已满; //表示缓冲区已满,索引=size -1且所有内存元素都存储时 //要写入 SD 卡的数据 }SDBuffer; uint32_t * sd_Buffer; uint32_t * tempsd_Buffer; struct SDBuffer SDbuffer; uint32_t * sd_addresses [2]; bool heap_set_up (){ /*初始化 SDBuffer 结构成员*/ SDbuffer.address = 0; SDbuffer.size =((buffer_size)/4);//除以4得到 uint32_t 的单位(4字节)、这是元素数量 SDbuffer.index = 0; SDbuffer.full = false; system_printf ("Buffer1 size before alloc:%d\n"、buffer_size);System_flush (); SD_Buffer =(uint32_t *) Memory_alloc (NULL、(buffer_size)、0、NULL);//乘以 datasize size_data_type_ADXL345 if (!SD_Buffer){ system_printf ("未为内存存储分配内存、正在中止...!\n");System_flush (); 返回 false; } tempSD_Buffer =(uint32_t *) Memory_alloc (NULL、(buffer_size)、0、NULL);//乘以 datasize size_data_type_AFE4404 if (!tempSD_Buffer){ system_printf ("未为内存存储分配内存、正在中止...!\n");System_flush (); 返回 false; } SD_addresses[0]= SD_Buffer; SD_addresses[1]= tempSD_Buffer; System_printf ("缓冲区大小:%d\n"、buffer_size);System_flush (); system_printf ("数字序列:%d\n"、NUM_sequence);System_flush (); 返回 true; }
当将这个相同的代码添加到新的 CC2642R1构建时、程序会从似乎缺少可用堆空间的情况下冻结 Memory_alloc()调用。 此新代码目前在360K 的16%上用于闪存、在81,920K 的23%上用于 SRAM。
是否对.cfg 文件或应该执行的任何其他模块进行了一些修改以使此构建正常工作?
谢谢。
-Stephen P.
嘿、Joakim、
我通读了该指南,没有看到任何具体涉及这一问题的适用案文。 在我的所有构建过程中(CC2640、CC2640R2和 CC2642R)、由于程序悬挂在 Memory_allocs()上、因此难以实现提供的代码。 我的问题需要解决的一部分是 Memory_alloc()从哪里获取它的内存。 我已经将默认堆大小设置为远远超出要求、但它仍然挂起。
以下是我的.cfg 文件中的一些设置:
是否对.cfg 文件或 CCS 中的其他任何地方进行了一些修改、以便使该构建正常工作?
您好!
我们的程序是基于 TI-RTOS 内核示例之一而构建的、因为我们没有计划使用任何外设或中央功能。
您是否说无法使用当前的内存分配方法?
谢谢