UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Participant sythez
Participant
857 Views
Registered: ‎03-22-2011

FreeRTOS version issue : ISR & Task

Jump to solution

Hello,

I am running my application which has interrupt and task in FreeRTOS Xilinx 8.2.3 (Vivado 2016.4) and it works fine.

I changed vivado version to 2017.3 and re-generate bsp and the version of FreeRTOS is 9.0.1.

 

the problem is ISR is not working with task. when the task is off, ISR(interrupt service routine) is fine. but when the task is started, ISR does not response. same code, only different bsp.

 

is there anyone has solution ?

0 Kudos
1 Solution

Accepted Solutions
Contributor
Contributor
750 Views
Registered: ‎09-10-2018

Re: FreeRTOS version issue : ISR & Task

Jump to solution

initialize_interrupts and configure_interrupts are functions that initialize ScuGic and configure ScuGic, respectively.

You cannot use ScuGicInterrupt_Init from the file you sent as that would re-initialize ScuGic and disconnect the interrupt FreeRTOS uses to run the scheduler, i.e. you need to write a function that does not initialize ScuGic, but adds your own interrupts to the already existing ScuGic configuration that FreeRTOS has made.

Another note is that you cannot use XScuTimer as it's used by FreeRTOS.

As XScuGic is already configured by FreeRTOS, all you need to do is connect and enable your interrupt:

extern XScuGic xInterruptController; /* The XScuGic configuration defined by FreeRTOS */

#define IRQ_ID 91 /* This is the ID of the interrupt you want to enable */
void irq_callback(void *ref); /* This is the callback function that is called when IRQ_ID occurs */

void ScuGicInterrupt_Connect(XScuGic *gic_ptr, u32 irq_id, void *irq_cb, void *irq_ref){ XScuGic_Connect(gic_ptr, irq_id, irq_cb, irq_ref);
XScuGic_Enable(gic_ptr, irq_id); }

/* This is the hook that will be called after vTaskStartScheduler, */
/* but before FreeRTOS starts. Remember to enable it! */
void vApplicationDaemonTaskStartupHook(){
ScuGicInterrupt_Connect(&xInterruptController, IRQ_ID, irq_callback, NULL);
}

int main(){
/* Do all xTaskCreates and so on */
vTaskStartScheduler();
}

Note that you might also need to configure the priority and trigger type of your interrupts using XScuGicSetPriorityTriggerType.

View solution in original post

6 Replies
Contributor
Contributor
828 Views
Registered: ‎09-10-2018

Re: FreeRTOS version issue : ISR & Task

Jump to solution

Does your task run within a critical section by chance?

 

When you say that "task is off" do you mean not running, or that vTaskStartScheduler has not been called at all?

0 Kudos
Participant sythez
Participant
806 Views
Registered: ‎03-22-2011

Re: FreeRTOS version issue : ISR & Task

Jump to solution

thanks for your reply,

and my task has critical section in/out function call.

I turned off task with "vTaskStartScheduler has not been called at all"

 

0 Kudos
Contributor
Contributor
791 Views
Registered: ‎09-10-2018

Re: FreeRTOS version issue : ISR & Task

Jump to solution

I have not used FreeRTOS 8.2.3 with Vivado 2016.4, but I have used FreeRTOS 10 in 2018.3, where you have to do the following to get ISRs to work:

FreeRTOS uses XScuGic and the private timer interrupt for scheduling. This means that vTaskStartScheduler will re-initialize XScuGic when vTaskStartScheduler is called, erasing any configurataion you have done.

/*
* This will not work!
*/ static XScuGic InterruptController; int main(){
initialize_interrupts(&InterruptController); /* Initializes XScuGic */
configure_interrupts(&InterruptController); /* Configures XScuGic */
vTaskStartScheduler(); /* Initializes and configures XScuGic */ }

My solution was to do something like this:

/*
* This works (at least in FreeRTOS 10 + SDK 2018.3)!
*/
extern XScuGic xInterruptController; /* Defined and configured by Free-RTOS */

/*This hook will be called after vTaskStartScheduler(), */
/* but before tasks are started. */
void
vApplicationDaemonTaskStartupHook(){
configure_interrupts(&xInterruptController);
}

int main(){
vTaskStartScheduler();
}

vApplicationDaemonTaskStartupHook has to be enabled. I did that through the RTOS_BSP settings:

hook.png

0 Kudos
Highlighted
Participant sythez
Participant
757 Views
Registered: ‎03-22-2011

Re: FreeRTOS version issue : ISR & Task

Jump to solution

thanks for your reply,

and what are  "initialize_interrupts" and "configure_interrupts" ?

I use the function "ScuGicInterrupt_Init()" in this link;

www.xilinx.com/Attachment/interrupt_app.c

0 Kudos
Contributor
Contributor
751 Views
Registered: ‎09-10-2018

Re: FreeRTOS version issue : ISR & Task

Jump to solution

initialize_interrupts and configure_interrupts are functions that initialize ScuGic and configure ScuGic, respectively.

You cannot use ScuGicInterrupt_Init from the file you sent as that would re-initialize ScuGic and disconnect the interrupt FreeRTOS uses to run the scheduler, i.e. you need to write a function that does not initialize ScuGic, but adds your own interrupts to the already existing ScuGic configuration that FreeRTOS has made.

Another note is that you cannot use XScuTimer as it's used by FreeRTOS.

As XScuGic is already configured by FreeRTOS, all you need to do is connect and enable your interrupt:

extern XScuGic xInterruptController; /* The XScuGic configuration defined by FreeRTOS */

#define IRQ_ID 91 /* This is the ID of the interrupt you want to enable */
void irq_callback(void *ref); /* This is the callback function that is called when IRQ_ID occurs */

void ScuGicInterrupt_Connect(XScuGic *gic_ptr, u32 irq_id, void *irq_cb, void *irq_ref){ XScuGic_Connect(gic_ptr, irq_id, irq_cb, irq_ref);
XScuGic_Enable(gic_ptr, irq_id); }

/* This is the hook that will be called after vTaskStartScheduler, */
/* but before FreeRTOS starts. Remember to enable it! */
void vApplicationDaemonTaskStartupHook(){
ScuGicInterrupt_Connect(&xInterruptController, IRQ_ID, irq_callback, NULL);
}

int main(){
/* Do all xTaskCreates and so on */
vTaskStartScheduler();
}

Note that you might also need to configure the priority and trigger type of your interrupts using XScuGicSetPriorityTriggerType.

View solution in original post

Participant sythez
Participant
731 Views
Registered: ‎03-22-2011

Re: FreeRTOS version issue : ISR & Task

Jump to solution

thanks for your reply,

I tried your solution at vivado 2017.3, FreeRTOS 9.0.1 and it solved !

there is no hookup in FreeRTOS 9.0.1 so I call your function at the beginning of my task before while loop.

Great help! thank you :)

however, I add two lines void ScuGicInterrupt_Connect() as below ;

 

Xil_ExceptionEnable();

XScuGic_SetPriorityTriggerType(gic_ptr, irq_id, 0x0, 3);

 

 

0 Kudos