【发布时间】:2017-09-20 20:24:11
【问题描述】:
我正在尝试了解 freeRTOS 中的内存分配方案 1。
在这个函数中,使用了以下代码。
static uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
static uint8_t *pucAlignedHeap = NULL;
if( pucAlignedHeap == NULL )
{
/* Ensure the heap starts on a correctly aligned boundary. */
pucAlignedHeap = ( uint8_t * ) ( ( ( portPOINTER_SIZE_TYPE ) &ucHeap[ portBYTE_ALIGNMENT ] ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) );
}
我正在研究 arm cortex m3 mcu。所以
portPOINTER_SIZE_TYPE defined as uint32_t
portBYTE_ALIGNMENT defined as 8
portBYTE_ALIGNMENT_MASK defined as 0x0007
为什么我们不能只使用 pucAlignedHeap = &ucHeap; ?
感谢您的回答。
【问题讨论】:
标签: memory-management arm memory-alignment freertos cortex-m