FreeRTOS porting to ARM926ejs

nagarajukarre wrote on Wednesday, October 09, 2013:

Thank you for your reply.

By doing the below changes i am able to run the multiple tasks.

I have created the three tasks in my main programme and started the scheduler.

In my each task entry i am enabling my IRQ interrupts and before exiting task disbaling the irq interrupts.

Why i enabled the interrupts:

I observed that once entering into the task interrupts are disabling and i am not getting the IRQ interrupts and contineously only that task is running.

Once i enabled the interrupts i am getting the interrupt and next task getting the cpu time slice and it is running. But these tasks are running in ARM IRQ mode.

my code looks like below.

void OSTimeTick( void )
{

    if( xTaskIncrementTick() != pdFALSE );
        {
   
            vTaskSwitchContext();
        }
        portRESTORE_CONTEXT();
  }

I have removed my portSAVE_CONTEXT code as i mentioned in my previous message.
Please correct me if i am wrong.

I will try now with suggested inputs.

Regards,

rtel wrote on Wednesday, October 09, 2013:

Are your clearing the timer interrupt anywhere? When a timer generates an interrupt it is normal for the interrupt handler to clear the interrupt in the peripheral. It is often additionally necessary to clear the interrupt in the interrupt controller too. How that is done is chip specific, and not FreeRTOS related, but it sounds like you might be missing that step somewhere.

Regards.

nagarajukarre wrote on Wednesday, October 09, 2013:

Thank you for your reply,

Yes i am clearing the my timer interrupt in my interrupt handler.
Once interrupt comes i am checking that this is timer interrupt, if it is timer interrupt then i am clearing the timer interrupt in my simple interrupt controller.

code looks like below.

void do_irq (void)
{

        if ((__read_irq_status) & (1<<IRQ_TIMER))
        {
            __clear_irq(IRQ_TIMER);

             if(rd_b(TIMERS_INTERRUPT_STATUS_REG)&2)
             {
                   OSTimeTick();
             }
        }
  }

As you have stated that it is chip specific.

Please could you guide me how to do the missing step (as present in FreeRTOS).

Regards,

rtel wrote on Wednesday, October 09, 2013:

I’m afraid without having the project and hardware in front of me I don’t know what the missing step is. OSTimeTick() should now just be a standard C function (not naked).

Regards.

nagarajukarre wrote on Thursday, October 10, 2013:

Please could you elaborate me on what is naked ? If OSTimeTick function is not naked how do i make it as naked?

Regards,

xz8987f wrote on Thursday, October 10, 2013:

for ARM gcc:
attribute ((naked)) void vPortTickHandler(void) …

Erich

xz8987f wrote on Thursday, October 10, 2013:

needs to have double underscore around attribute:

__attribute__ ((naked)) void vPortTickHandler(void) ...

nagarajukarre wrote on Thursday, October 10, 2013:

is it true for arm-none-eabi-gcc ?

In case od ARM will jump into the generic handler called do_irq() inside this handlwe will check for which peripheral has raised the interrupt then will call the OSTimeTick().

Please could you suggest me now i have to made OSTimeTick() as naked or do_irq() naked?

Regards ,

rtel wrote on Thursday, October 10, 2013:

As already said - if you are using a single interrupt entry point that is saving the task context, then determining the interrupt source, then calling the appropriate C function to handle the interrupt source…the C function that is called should be a standard C function - not a naked function.

All the stack manipulation and context saving and restoring is performed in just on place - the IRQ entry point. After that everything is just C code managed by the compiler.

Regards.

nagarajukarre wrote on Thursday, October 10, 2013:

Thank you for your reply.

I observed the code for Cortex-M3 and i found the below observations.

void xPortSysTickHandler( void ) and

void xPortPendSVHandler( void ) inside this handler we are getting the current TCB and saving all the processor registers and calling
bl vTaskSwitchContext and restoring the context.

Whenever the timer gets expired xPortSysTickHandler() function will be called and timer tick count gets incremented.

Please could you clarify me the below.When the below handlers are going to be called and where we are registering thse handlers.

vPortSVCHandler() and void xPortPendSVHandler( void )

Regards,