Porting FreeRTOS 10.0.0 to LPC2148
I am trying to get FreeRTOS running on LPC2148. I am able to call my task function.
Inside my task funtion I want to have a delay and hence called vTaskDelay(0) (to first test things out I have zero timeout). However I dont think my task is called again, i.e, brought back to RUNNING state again..
I stepped through, the functions called by vTaskDelay(0). They are
vTaskDelay(0)->portYIELDWITHINAPI()->vPortYield
(I’ve taken portASM.s from FreeRTOSv10.0.0FreeRTOSv10.0.0FreeRTOSSourceportableRVDSARM7_LPC21xx)
and this lands up in the “SWIHandler B SWIHandler” defined in Startup.s .
The debugger dosent proceed further . I’ve set INCLUDE_vTaskDelay = 1 in FreeRTOSConfig.h
Can anyone tell me how to proceed ?
Does the exisiting PortYield function need to be modified ?
Exisiting vPortYield functions is,
vPortYield
PRESERVE8
SVC 0
bx lr
Porting FreeRTOS 10.0.0 to LPC2148
and this lands up in the “SWIHandler B SWIHandler” defined in Startup.s .It looks like you are using the default SWI handler, which does nothing but jump to itself, so once it is entered it never exits. You need to have the SWI handler jump to the FreeRTOS SWI handler, which in your case is called vPortYieldProcessor. However you don’t want to try branching to it directly, as it may be located in memory that is too far away for a simple ‘b’ branch – instead branch to it indirectly by loading its address. Your vector table will then look something like this (which I have taken from here https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Demo/ARM7LPC2129Keil_RVDS/Startup.s):
Vectors LDR PC, Reset_Addr LDR PC, Undef_Addr LDR PC, SWI_Addr ; LOAD PC WITH ADDRESS AT SWI_Addr LDR PC, PAbt_Addr LDR PC, DAbt_Addr NOP LDR PC, [PC, #-0x0FF0] LDR PC, FIQ_Addr Reset_Addr DCD Reset_Handler Undef_Addr DCD Undef_Handler SWI_Addr DCD vPortYieldProcessor ; FreeRTOS SWI HANDLER PAbt_Addr DCD PAbt_Handler DAbt_Addr DCD DAbt_Handler IRQ_Addr DCD IRQ_Handler FIQ_Addr DCD FIQ_Handler
Porting FreeRTOS 10.0.0 to LPC2148
Thanks Richard, its worked