Interrupts and FreeRTOS

qasimzca wrote on Saturday, October 07, 2017:

I am using ARM Cortex-M4 core-based MT2523G microcontroller. My issues that, when I use interrupts with FreeRTOS, I never receive an interrupt. For example, I am using external interrupts in my code. Without FreeRTOS the interrupts are working perfect. But whenever I try to use any kind of interrupts with FreeRTOS, no interrupts is generated. I tried to check weather interrupts are disable or not but I could not find any solution.

Please guide me how can i enable interrupts while using FreeRTOS.

NOTE: Interrupts are perfectly working without FreeRTOS

rtel wrote on Saturday, October 07, 2017:

Are you encountering this problem before or after starting the
scheduler? If you have made calls to the FreeRTOS API, but not started
the scheduler, then it is expected that interrupts will be disabled.
That is done deliberately to prevent interrupt service routines
attempting to perform a context switch before the scheduler is running.
Interrupts are automatically re-enabled when the first task starts running.

qasimzca wrote on Monday, October 09, 2017:

My code is shown below. I have created the task that continuously prints a string on screen. But, interrupts are still not working

int main(void)
/* Do system initialization, eg: hardware, nvdm. */

log_init(NULL, NULL, NULL);

LOG_I(template, "start to create task.\n");

/*this function initializes the GPIOs and external interupts */

BaseType_t pdchk;
if((pdchk = xTaskCreate(print_task,"idle",2048,NULL,1,NULL)) == pdPASS){
    LOG_I(template, "\n\r idle create\n\r");

/* Call this function to indicate the system initialize done. */

/* Start the scheduler. */

for (;;);


rtel wrote on Monday, October 09, 2017:

The last thing vTaskStartScheduler() does is call into the portable
layer, which enables interrupts globally, clears the BASEPRI register so
no interrupts are masked, then starts the first task.

Is the first task starting? How do you know? If you put a break point
at the start of the first task, before it does anything (even before it
modifies the stack frame) what values do the I bit (global interrupt
disable) and BASEPRI registers hold?

If you step through prvStartFirstTask() (line 303 on the following link
at the time of writing:
you will see the cpsie i instruction, which enables global interrupts.
It then executes svc 0, which results in vPortSVCHandler() executing
(line 284 on the same link at the time of writing), where you will see
it loads basepri with 0. If the first task has started, then those
lines must have executed. If you step through those functions, what do
you see happening?

qasimzca wrote on Wednesday, October 11, 2017:

My interrupts have started working now.
When I introduced a delay inside my first task using for loop, just for test purposes, I started getting interrupts.
But now the situation is if delay is much smaller, then i am getting interrupts without any event. I am not able to understand why is this happening and why i don’t get interrupts if i don’t introduce delay inside my task.

rtel wrote on Wednesday, October 11, 2017:

By ‘interrupts’ do you mean context switching from one task to another,
or do you mean all interrupts. How are you determining this? Are you
actually looking at the register values in the chip or just observing