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.
大家好。
我已经成功地在 新型TMS320F28.0039万c上从该存储库( github.com/.../freertos_c28x )调整FreeRTOS并使其正常工作。 但它只适用于一个任务,当我添加第二个任务时,它不起作用。 当系统进入第二个指令时 ,它会被冻结,它会尝试执行无效的指令。 只有一个任务在运行时,系统工作正常,即使是队列和延迟也是如此。 我比较了这两个版本的地图,有很多不同方向的函数。 可能是 对pxPortInitializeStack()所做的一些假设不适用于新的EABI。 当您有第二个任务时,它使用TickISR函数内的代码输入该函数,但第一个任务使用portRestore First上下文输入。 代码已附加
我非常感谢您提供的任何帮助。
此致
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) { volatile uint16_t i; base = 0; pxTopOfStack[base++] = 0x0080; // ST0. PSM = 0(No shift) pxTopOfStack[base++] = 0x0000; // T pxTopOfStack[base++] = 0x0000; // AL pxTopOfStack[base++] = 0x0000; // AH pxTopOfStack[base++] = 0xFFFF; // PL pxTopOfStack[base++] = 0xFFFF; // PH pxTopOfStack[base++] = 0xFFFF; // AR0 pxTopOfStack[base++] = 0xFFFF; // AR1 pxTopOfStack[base++] = 0x8A08; // ST1 pxTopOfStack[base++] = 0x0000; // DP pxTopOfStack[base++] = 0x2000 | IER; // IER at the moment of creating tasks, make sure INT14 is enabled pxTopOfStack[base++] = 0x0000; // DBGSTAT pxTopOfStack[base++] = ((uint32_t)pxCode) & 0xFFFFU; // PCL pxTopOfStack[base++] = ((uint32_t)pxCode >> 16) & 0x00FFU; // PCH pxTopOfStack[base++] = 0xAAAA; // Alignment pxTopOfStack[base++] = 0xBBBB; // Alignment // Fill the rest of the registers with dummy values. for(i = 0; i < (2 * AUX_REGISTERS_TO_SAVE); i++) { uint16_t low = 0xAAAA; uint16_t high = 0xAAAA; if(i == (2 * XAR4_REGISTER_POSITION)) { low = ((uint32_t)pvParameters) & 0xAAAAU; high = ((uint32_t)pvParameters >> 16) & 0xAAAAU; } #if defined(__TMS320C28XX_FPU32__) if(i == (2 * STF_REGISTER_POSITION)) { uint32_t stf = getSTF(); low = stf & 0xAAAAU; high = (stf >> 16) & 0xAAAAU; } #endif pxTopOfStack[base + i] = low; i++; pxTopOfStack[base + i] = high; } base += i; // Reserve place for ST1 which will be used in context switch // to set correct SPA bit ASAP. pxTopOfStack[base++] = 0x8A18; // ST1 with SPA bit set pxTopOfStack[base++] = 0x0000; // DP pxTopOfStack[base++] = 0x0000; // placeholder for 32 bit ulCriticalVars pxTopOfStack[base++] = 0x0000; // Return a pointer to the top of the stack we have generated so this can // be stored in the task control block for the task. return pxTopOfStack + base; } portRESTORE_FIRST_CONTEXT ; Restore stack pointer from new task control block. MOVL XAR0, #pxCurrentTCB MOVL XAR0, *XAR0 MOVL XAR0, *XAR0 MOV @SP, AR0 ; Restore XAR4 and RPC from saved task stack. ; and return to main task function. ; SP should be set to stack start plus 2 before LRETR. SUBB SP, #XAR4_DELTA POP XAR4 SUBB SP, #RPC_DELTA POP RPC SUBB SP, #SP_TOP_DELTA CLRC INTM, DBGM ; renable global interrupts LRETR .endasmfunc And this is the part of Restore Context inside the ISR RESTORE_CONTEXT: POP DP:ST1 .if .TMS320C2800_FPU32 = 1 MOV32 R7H, *--SP MOV32 R6H, *--SP MOV32 R5H, *--SP MOV32 R4H, *--SP MOV32 R3H, *--SP MOV32 R2H, *--SP MOV32 R1H, *--SP MOV32 R0H, *--SP MOV32 STF, *--SP POP RB .endif POP XAR7 POP XAR6 POP XAR5 POP XAR4 POP XAR3 POP XAR2 POP XT POP RPC POP AR1H:AR0H NASP IRET
您好,
您是否在项目中使用动态分配? 请检查所有任务的任务堆栈是否分配给有效的内存部分。
谢谢
Vasudha