rtimenoob wrote on Thursday, April 13, 2017:
Hello,
thank u very much for your answer.
Unfortunatelly I wasn’t able to get it running.
Although in the datasheet is said BASPRI priority bits are [7:4] (4 BITS!!!) the definition for configPRIO_BITS in CMSIS is 3. I do not understand this.
Because I am not sure what is right, I am still using the above settings (4 Bits).
My problem is not, that I am not able to start the Scheduler.
I jump into dummy_handler (Hard Fault) when I hit the function
vTaskStartScheduler()–>xTaskCreate(prvIdleTask,…)–>xTaskGenericCreate(…)–>taskYIELD_IF_USING_PREEMPTION()–>xPortPendSVHandler()
Here I can step through, up to line “stmdb r0!, {r4-r11, r14}”. After that line I directly jump into dummy_handler() because of Hard Fault Error Interrupt.
void xPortPendSVHandler( void )
{
/* This is a naked function. */
__asm volatile
(
" mrs r0, psp \n"
" isb \n"
" \n"
" ldr r3, pxCurrentTCBConst \n" /* Get the location of the current TCB. */
" ldr r2, [r3] \n"
" \n"
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, push high vfp registers. */
" it eq \n"
" vstmdbeq r0!, {s16-s31} \n"
" \n"
" stmdb r0!, {r4-r11, r14} \n" /* Save the core registers. */
" \n"
" str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */
" \n"
" stmdb sp!, {r3} \n"
" mov r0, %0 \n"
" cpsid i \n" /* Errata workaround. */
" msr basepri, r0 \n"
" dsb \n"
" isb \n"
" cpsie i \n" /* Errata workaround. */
" bl vTaskSwitchContext \n"
" mov r0, #0 \n"
" msr basepri, r0 \n"
" ldmia sp!, {r3} \n"
" \n"
" ldr r1, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. */
" ldr r0, [r1] \n"
" \n"
" ldmia r0!, {r4-r11, r14} \n" /* Pop the core registers. */
" \n"
" tst r14, #0x10 \n" /* Is the task using the FPU context? If so, pop the high vfp registers too. */
" it eq \n"
" vldmiaeq r0!, {s16-s31} \n"
" \n"
" msr psp, r0 \n"
" isb \n"
" \n"
#ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata workaround. */
#if WORKAROUND_PMU_CM001 == 1
" push { r14 } \n"
" pop { pc } \n"
#endif
#endif
" \n"
" bx r14 \n"
" \n"
" .align 2 \n"
"pxCurrentTCBConst: .word pxCurrentTCB \n"
::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY)
);
}
I also tried it with 3 bit and the following settings:
configMAX_PRIORITIES ((unsignes portBASE_TYPE) 5 )
configPRIO_BITS 3
configLIBRARY_LOWEST_INTERRUPT_PRIORITY 0x07
configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 1
configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
but without any success.
I am using freertos 8.2.3 and I don’t know what to do.
here is my small application code:
void User_init_tasks(void)
{
xTaskHandle xINITHandle;
portBASE_TYPE retVal=0;
//Start init Task
retVal = xTaskCreate( init_task, // Function
( signed portCHAR * ) "INIT_Task", // Name
256, // Stack Size
NULL, // Parameter
tskIDLE_PRIORITY, // Prio
&xINITHandle ); // Handel
/* Start the scheduler. */
vTaskStartScheduler();
/* Will only get here if there was insufficient memory to create the idle
task. */
return 0;
}
void init_task(void *pvParameters)
{
(void) pvParameters;
portBASE_TYPE OK = pdPASS;
//Blinky Task
OK = xTaskCreate(Blink, "Blinky",
TASK_LED_STACK_SIZE,
NULL,
TASK_LED_PRIORITY,
&System.taskhandles[LED_HANDLE]);
// OK |= xTaskCreate(vStartEthernetTask, "ETHLAUNCH",
// configMINIMAL_STACK_SIZE,
// NULL,
// tskIDLE_PRIORITY,
// NULL);
// OK |= xTaskCreate(CAN_TO_ETH_TASK, "CAN_TO_ETH",
// CAN_TO_ETH_TASK_STACK_SIZE,
// NULL,
// CAN_TO_ETH_TASK_PRIORITY,
// &System.taskhandles[CAN_TO_ETHER_HANDLE]);
//if(OK != pdPASS)
//set_SystemStatus(SYSTEM_ERROR, 2);
vTaskDelete(xTaskGetCurrentTaskHandle());
}
//Blink Task alle 200ms
void Blink(void *pvParameters)
{
portTickType xLastWakeTime;
const portTickType xFrequency = LIFE_PULS_CYCLE_TIME_MS;
xLastWakeTime = xTaskGetTickCount();
for(;;)
{
ioport_toggle_pin_level(LED_ON);
vTaskDelayUntil(&xLastWakeTime, xFrequency); //Pause
}
}
User_init_tasks() I am calling from my main().
I am really looking forwars to your ansers.
Thank u very much.