STR912 GCC Tick problem

jlbosa wrote on Thursday, January 31, 2008:

I ported FreeRTOS IAR to GCC using Ride.
I can to create a Task for test and run good when I don´t use delay.
So when I use vTaskDelayUntil the scheduler never finish, and the kernel never return to execute the task. In debug mode, I found out the problem occur in WDG_IRQHandler, because in assemble debug the instruction don´t start in begin of the function, but start in the instruction os reset the WDG (WDG->SR &= ~0x0001;) and after execute the vPortEnterCritical and vPortExitCritical and return to WDG Reset, and so on.

My kernel can´t use task delay because this problem.

How to solve this problem?


rtel wrote on Friday, February 01, 2008:

I’m not sure if I understand the description of your problem exactly.  I am assuming you are using the watchdog peripheral to generate the tick interrupt.  Is this correct?

I’ve just checked the STR75x RIDE port to see how the interrupt is set up.  In this example the file crt0_STR75x_FreeRTOS.s has been updated to place the vPortTickISR handler on the TB peripheral (would be the watchdog peripheral in your case).  Also the IRQ handler itself is written as:


    portSAVE_CONTEXT    /*; Save the context of the current task. */

    LDR    r0, =EIC_base_addr
    LDR    r1, =IVR_off_addr
    LDR    lr, =ReturnAddress /*; Load the return address. */
    ADD    pc,r0,r1        /*; Branch to the IRQ handler. */
    LDR    r0, =EIC_base_addr
    LDR    r2, [r0, #CICR_off_addr]    /*; Get the IRQ channel number. */
    MOV    r3,#1
    MOV    r3,r3,LSL r2
    STR    r3,[r0, #IPR_off_addr]    /*; Clear the corresponding IPR bit. */
    portRESTORE_CONTEXT        /*; Restore the context of the selected task. */

to ensure the context is saved prior to the branch to vPortTickISR.

This is just one method of doing this, whereby the context is saved and restored by a single IRQ handler before jumping to the peripheral handler.  Other examples jump directly to the peripheral handler where the handler can decide if it needs to save and restore the context of not.

vPortTickISR is defined within portISR.c, which must be compiled into ARM mode.

How have you setup your interrupt?


ben_fnr wrote on Friday, February 01, 2008:

I have got a GCC port working for the STR9, although at the moment it is only running 1 task with a vTaskDelayUntil to flash an LED. I based it on a STR75c GCC port.

I have it configured to use any one of the 4 timers, I wanted to keep the watchdog timer free in case I needed to use it as a watchdog.

I am using it with Eclipse, but you are welcome to a copy if it will help you.


jlbosa wrote on Friday, February 01, 2008:

Hi, my interrupt was setuped using same as port ARM9 IAR.
I use the file boot.s that I got in site in example an2551.

My IRQ handler itself is written as:
      LDR    r0, =VIC0VECT
      LDR    r0, [r0]   
      LDR    r1, =VIC1VECT
      LDR    r1, [r1]
      MOV    lr, pc   
      BX     r0       
      LDR    r0, =VIC0VECT
      STR    r0, [r0]
      LDR    r1, =VIC1VECT
      STR    r1, [r1]

And the SWIHandler itself is written as:
        ADD    LR, LR, #4   
    LDR R0, =vTaskSwitchContext   
    MOV  lr, pc
    BX   R0

The instructions in portmacro.h , the portDISABLE_INTERRUPTS() and portENABLE_INTERRUPTS() are the same the port ARM7_STR75x_GCC.

And I didn´t use the portISR.c, because I do everything in the port.c. Maybe here is my problem.

Ben, could you send your port for my email?