FreeRTOS vApplicationSetupHardware()

25 篇文章 0 订阅
15 篇文章 1 订阅

URL: http://www.freertos.org/Interactive_Frames/Open_Frames.html?http://interactive.freertos.org/forums

*****************************************************************************************************************************************************************************************

Hi, We write a code below to use FPGA interrupt instead of timer interrupt set up by FreeRTOS. The prototype of vApplicationSetupHardware() is defined in portmacro.h and its implemented can be in main.c.  It will execute in xPortStartScheduler() that will enable timer interrupt by FreeRTOS porting. So in this function it will disable/disconnect timer interrupt first, then it will connect vTickISR and your own interrupt ID. Any comments for this will be very useful for us, thank you.

Code:

void vApplicationSetupHardware( void )
{
/* Do nothing */

// ********************************************************
// NOTE:
// This function is executed in xPortStartScheduler( void )
// ********************************************************

extern void vTickISR (void);
XScuGic *pObj;
U32 time = 44400; // time = 888us / 0.02us

// Get interrupt controller pointer from FreeRTOS
pObj = prvGetInterruptControllerInstance();

// Disable and disconnect timer interrupt generated from FreeRTOS
XScuGic_Disable( pObj, XPAR_SCUTIMER_INTR );
XScuGic_Disconnect( pObj, XPAR_SCUTIMER_INTR );

// Setup FPGA register to generate interrupt
Xil_Out32( 0x41200000, time | 0x80000000 );

// Enable FPGA interrupt
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
(Xil_ExceptionHandler) XScuGic_InterruptHandler,
(void *) pObj);
XScuGic_Connect( pObj, 61, (Xil_ExceptionHandler)vTickISR, (void *)pObj );
XScuGic_Enable( pObj, 61 );
Xil_ExceptionEnable();
XScuGic_SetPriorityTriggerType( pObj, 61, 0xa0, 3);

}

*****************************************************************************************************************************************************************************************

Note in the official Zynq demo the timer interrupt is configured in an application callback anyway.  http://www.freertos.org/RTOS-Xilinx-Zynq.html

*****************************************************************************************************************************************************************************************

In the application vApplicationSetupHardware(), you need to call just the initialization for all the interrupt handler. Place this code into some function named e.g. FPGA_Interrupt_init and call this function from the  vApplicationSetupHardware(). Are u receiving interrupt in your program or not? One more thing you do not need  "Disable and disconnect timer interrupt generated from FreeRTOS" line. Follow the following sequence

1. Get Interrupt controller Instance

2. Lookup for specific device

3. Initialize the device  _CfgInitilization(   ).

4. connect the device interrupt with the interrupt controller        XScuGic_Connect()

5. Enable interrupt in the interrupt controller XScuGic_Enable

6. set some other setting for the specific device etc.



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值