PYNQ Arduino IOPでタイマー割込み(その2)

【追記】以下のコードは複数タイマで動かない→修正した( http://d.hatena.ne.jp/seinzumtode/20180419/1524107851
インスタンス名をARM Cortex A-9コアでやったとき(= http://d.hatena.ne.jp/seinzumtode/20171011/1507704033 )と合わせてみた

#include <stdio.h>
#include "xil_types.h"
#include "xtmrctr.h"
#include "xparameters.h"
#include "xil_io.h"
#include "xil_exception.h"
#include "xintc.h"
#include "xgpio.h"

void Timer_InterruptHandler(void *data, u8 TmrCtrNumber)
{
	print(" Interrupt acknowledged \n \r ");
}

int main()
{
	XIntc IntcInstancePtr;
	XTmrCtr TimerInstancePtr;
	int xStatus;
	print("##### Application Starts #####\n\r");
	print("\r\n");
	xStatus = XTmrCtr_Initialize(&TimerInstancePtr,XPAR_TMRCTR_0_DEVICE_ID);
	if(XST_SUCCESS != xStatus)
		print("TIMER INIT FAILED \n\r");

	XTmrCtr_SetHandler(&TimerInstancePtr,Timer_InterruptHandler,&TimerInstancePtr);
	XTmrCtr_SetResetValue(&TimerInstancePtr,0, 0xf8000000);
	XTmrCtr_SetOptions(&TimerInstancePtr,XPAR_TMRCTR_0_DEVICE_ID,(XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION ));

	xStatus = XIntc_Initialize(&IntcInstancePtr, XPAR_INTC_0_DEVICE_ID);
	if (xStatus != XST_SUCCESS){
		print("intc init error\n\r");
		return xStatus;
	}
	xStatus = XIntc_Connect(&IntcInstancePtr, XPAR_TMRCTR_0_DEVICE_ID,
			(XInterruptHandler)XTmrCtr_InterruptHandler,
			(void*)&TimerInstancePtr);
	if (xStatus != XST_SUCCESS){
		print("connect error\n\r");
		return xStatus;
	}
	 xStatus = XIntc_Start(&IntcInstancePtr, XIN_REAL_MODE);
	 if (xStatus != XST_SUCCESS){
		 print("intc start error\n\r");
		 return xStatus;
	 }
	 XIntc_Enable(&IntcInstancePtr, XPAR_INTC_0_DEVICE_ID);
	 microblaze_enable_interrupts();

	XTmrCtr_Start(&TimerInstancePtr,0);
	print("timer start \n\r");

	//Wait For interrupt;
	print("Wait for the Timer interrupt to tigger \r\n");
	print("########################################\r\n");
	print(" \r\n");

	while(1)
	{
	}
	cleanup_platform();
	return 0;
}