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.
我有一个在 FreeRTOS v9上运行的 Hercules 安全开发套件。 我使用的是 Code Composer Studio v11和 HALCoGen v4。
我的程序在 printf()中挂起。 SCI 工作正常。 我包含了 stdio.h 库。 构建代码时不会出现任何问题。 由于我对这个平台很陌生、我肯定会错过一些东西。
下面给出了一个测试代码片段
#include "FreeRTOS.h" #include "os_task.h" #include "HL_sci.h" #include "HL_het.h" #include "HL_gio.h" #include "stdio.h" #include "HL_sys_common.h" #define UART sciREG1 #define LENGTH 18 xTaskHandle xTas1kHandle, xTask2Handle; uint8 TEXT[LENGTH] = {'B', 'u', 't', 't', 'o', 'n', ' ', 'i', 's', ' ', 'p', 'r', 'e', 's', 's', 'e', 'd', ' '}; void consolePrint(sciBASE_t *sci, uint8 *text, uint32 length){ while(length--){ while((sci->FLR & 0x4) == 4); sciSendByte(sci, *text++); } } void vTask1(void *pvParameters){ for(;;){ gioSetBit(hetPORT1, 0, (gioGetBit(hetPORT1, 0)^1)); printf("Hello World\n\r"); //code hangs here vTaskDelay(100); } } void vTask2(void *pvParameters){ for(;;){ if((gioGetBit(gioPORTA, 7) == 0)){ consolePrint(UART, &TEXT[0], LENGTH); vTaskDelay(100); } } } int main(void) { sciInit(); gioSetDirection(hetPORT1, 0xFFFFFFFF); gioSetDirection(gioPORTA, 0x00000000); if (xTaskCreate(vTask2, "Task 2", configMINIMAL_STACK_SIZE, NULL, 1, &xTask2Handle) != pdTRUE){ while(1); } if (xTaskCreate(vTask1, "Task 1", configMINIMAL_STACK_SIZE, NULL, 1, &xTas1kHandle) != pdTRUE){ consolePrint(UART, &TEXT[0], LENGTH); } vTaskStartScheduler(); while(1); return 0; }
有人能帮我解决这个问题吗? 任何建议均可获得采纳。
谢谢你。
此致
Ua
您好、UA、
printf()采用较大的堆栈,请 从 HALCoGen GUI 调整 STACKSIZE:
HalCoGen->RAM->UserStack
您可以更改 sys_core.asm 中手动定义的堆栈大小:
_coreInitStackPointer_
感谢王杰的回复。 但它没有解决这个问题。
案例1
.def _coreInitStackPointer_ .asmfunc _coreInitStackPointer_ cps #17 ldr sp, fiqSp cps #18 ldr sp, irqSp cps #19 ldr sp, svcSp cps #23 ldr sp, abortSp cps #27 ldr sp, undefSp cps #31 ldr sp, userSp bx lr userSp .word 0x08000000+0x00000900 svcSp .word 0x08000000+0x00000900+0x00000100 fiqSp .word 0x08000000+0x00000900+0x00000100+0x00000100 irqSp .word 0x08000000+0x00000900+0x00000100+0x00000100+0x00000100 abortSp .word 0x08000000+0x00000900+0x00000100+0x00000100+0x00000100+0x00000100 undefSp .word 0x08000000+0x00000900+0x00000100+0x00000100+0x00000100+0x00000100+0x00000100 .endasmfunc
情况2.
.def _coreInitStackPointer_ .asmfunc _coreInitStackPointer_ cps #17 ldr sp, fiqSp cps #18 ldr sp, irqSp cps #19 ldr sp, svcSp cps #23 ldr sp, abortSp cps #27 ldr sp, undefSp cps #31 ldr sp, userSp bx lr userSp .word 0x08000000+0x00050000 svcSp .word 0x08000000+0x00050000+0x00000100 fiqSp .word 0x08000000+0x00050000+0x00000100+0x00000100 irqSp .word 0x08000000+0x00050000+0x00000100+0x00000100+0x00000100 abortSp .word 0x08000000+0x00050000+0x00000100+0x00000100+0x00000100+0x00000100 undefSp .word 0x08000000+0x00050000+0x00000100+0x00000100+0x00000100+0x00000100+0x00000100 .endasmfunc
在这两种情况下,程序都在 printf()中挂起。
谢谢你。
此致
Ua
我的差。 请使用 Chester 的方法来增加任务1的堆栈大小。