【发布时间】:2017-05-05 20:44:55
【问题描述】:
我正在使用基于微控制器 STM32F401RET6 的板 Nucleo F401Re。我将一个 Micro SD 插槽连接到板上,并有兴趣将数据写入 SD 卡并从中读取数据。我使用软件 STM32CubeX 来生成代码,特别是带有内置函数的 SD 库。我试图编写一个简单的代码,它将一个数组写入一个特定的数组并尝试在后面读取相同的数据。代码如下:
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_SDIO_SD_Init();
char buffer[14] = "Hello, world\n";
uint32_t to_send[512] ; // Te
uint32_t to_receive[512];
uint64_t address = 150;
HAL_SD_WriteBlocks(&hsd, to_send, address, 512, 1);
HAL_SD_ReadBlocks(&hsd, to_receive, address, 512, 1);
while (1)
{
HAL_UART_Transmit(&huart2, (uint8_t *)buffer, 14, 1000);
HAL_UART_Transmit(&huart2, (uint8_t *)to_receive, 512, 1000);
}
代码在函数 HAL_Init() 中间停止,我收到以下消息:
The stack pointer for stack 'CSTACK' (currently 0x1FFFFD30) is outside the stack range (0x20000008 to 0x20000408)
当我不使用函数 HAL_SD_WriteBlocks() 或 HAL_SD_ReadBlocks() 时,不会出现此消息。如果有人已经遇到这个问题并且知道如何解决它,那么一些帮助会拯救我。如果需要,我可以添加其余代码。
【问题讨论】:
标签: c stm32 iar stm32f4discovery