Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

custom ISR on Zynq702 fpga and

Posted by hiddenbitious on July 5, 2014

Hello all. I'll try to be brief with my problem.

I'm working on a zynq 702 board which is programmed with a custom hardware. Currently i'm adapting the CORTEXA9ZYNQ demo for my purposes.

The hardware, on certain occasions, raises an interrupt which i'm trying to catch and by using a semaphore to synchronize my task with my hardware. So far i have managed to catch the interrupt but i'm getting an assertion failure at tasks.c:2360 (configASSERT( pxUnblockedTCB );)

My code: Modified Demo/CORTEXA9ZynqZC702/RTOSDemo/src/FreeRTOStick_config.c: vConfigureTickInterrupt()

// Install the foo ISR.
extern void rtos_fooISR(void *data) /*__attribute__ ((isr))*/;
/// (notice i don't use the __attribute__ (isr), more on this later)

XScuGic_SetPriorityTriggerType( &xInterruptController, 90, (configMAX_API_CALL_INTERRUPT_PRIORITY) << portPRIORITY_SHIFT, ucRisingEdge);
xStatus = XScuGic_Connect( &xInterruptController, 90, (Xil_ExceptionHandler) rtos_fooISR, NULL);
configASSERT( xStatus == XST_SUCCESS );
( void ) xStatus;
XScuGic_Enable(&xInterruptController, 90);

Somewhere in main i initialize the binary semaphore: BaseType_t status; (void) status;

/// Initialize semaphore
foo_Semaphore = xSemaphoreCreateBinary();
configASSERT(foo_Semaphore != NULL);

status = xSemaphoreGive(foo_Semaphore);
configASSERT(status == pdTRUE);

Here is the ISR: void rtosfooISR(void *data) { static BaseTypet xHigherPriorityTaskWoken = 0; static volatile unsigned int *regaddr = (unsigned int *)(BASE + fooINTERRUPT); (void) data; /// Clear interrupt *regaddr = 0x1; /// "give" semaphore /// xilprintf("gnr"); xSemaphoreGiveFromISR(fooSemaphore, &xHigherPriorityTaskWoken); portYIELDFROM_ISR(xHigherPriorityTaskWoken); }

And this is the function the task calls when it wants to synchronize with the hardware void rtoswaitForfoo(void) { xilprintf("tnr"); xSemaphoreTake(fooSemaphore, portMAXDELAY); }

Is my code correct or i'm using a hack without being aware of it? Any idea why i get the assertion failure?

Also when i declare the rtos_fooISR function with the attribute((isr)) it appears that the interrupt stays on for ever. Why is that?

Thanks for your time.


custom ISR on Zynq702 fpga and

Posted by rtel on July 5, 2014

I cannot see anything that is obviously wrong in your code. You definitely don't want to use the attribute on your ISR handler as that will cause the compiler to add interrupt handling prologue and epilogue code that will not be compatible with the FreeRTOS interrupt entry point. There is a single interrupt entry point that already contains the necessary prologue code before calling your handler as a standard C function.

The assert that is failing is inside the xTaskRemoveFromEventList() function - which will be getting called from your interrupt handler, but probably from other places too. Is the assert failing from inside your handler (so from inside the xSemaphoreGiveFromISR() function)?

Regards.


custom ISR on Zynq702 fpga and

Posted by hiddenbitious on July 6, 2014
Is the assert failing from inside your handler (so from inside the xSemaphoreGiveFromISR() function)?

I'm not sure about that. How can i check it?


custom ISR on Zynq702 fpga and

Posted by davedoors on July 6, 2014

Two ways. When you hit the assert in the debugger either look at the call stack to see the function call path to the assert or step out of the assert function in the debugger to see where it returns too.

This is Eclipse right? If so the call stack is shown in the threads window, normally the top left window in the debug perspective.


custom ISR on Zynq702 fpga and

Posted by hiddenbitious on July 6, 2014
When you hit the assert in the debugger 

I'm not sure how to use the debugger. Currently i write a single image file which contains the hw spec the rtos plus a small library which is my task (which is the only task i create) on an sd card and boot the zynq board with it.

This is Eclipse right?

Yes i use the eclipse but just to compile the project. After that i write the image on the sd card.

Removing the xSemaphoreGiveFromISR(fooSemaphore, &xHigherPriorityTaskWoken); from the ISR the task (as excpected) hangs for ever in the rtoswaitForfoo() function.

If i remove the xSemaphoreTake(fooSemaphore, portMAXDELAY); from the rtos_waitForfoo() function too, then the same assertion failure happens.

Thanks for the replies. I really appreciate it.


custom ISR on Zynq702 fpga and

Posted by hiddenbitious on July 6, 2014

Alright i believe i have found the root of my problem.

It appears that i was causing a memory corruption by writing outside an array allocated with heap_1

Thank you for your replies and your time.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists