Jump to content
  • 0

Microblaze AXI Timer on Arty A7-35


penguin

Question

Hi. I am new to Vivado platform / Digilent's Arty board. 

I am trying to get Microblaze to work with Axi timer to trigger interrupt at a certain rate. 

 

The image below shows the overall architecture.
image.thumb.png.d85a96e755249888f73011326cf2bd0e.png

 

The board is successfully talking via UART and I can print on Terminal.

I compiled the code below and no error came up; I ran the program but the interrupt is not triggered at all.

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xintc.h"
#include "xtmrctr.h"		
#include "xparameters.h"
#include "xil_exception.h"
#include "xstatus.h"

XTmrCtr TimerCounterInst;
XIntc InterruptController;

#define TMRCTR_DEVICE_ID	XPAR_TMRCTR_0_DEVICE_ID
#define INTC_DEVICE_ID		XPAR_INTC_0_DEVICE_ID
#define TMRCTR_INTERRUPT_ID	XPAR_INTC_0_TMRCTR_0_VEC_ID
#define TIMER_CNTR_0		0
#define RESET_VALUE		500000

void TimerCounterHandler(void *CallBackRef, u8 TmrCtrNumber);
//static int count = 0;
volatile int TimerExpired;

int main()
{
	/* Initialization */
	XStatus  status;
	// 1. Platform
  	init_platform();
	print("Platform initialized \r\n");
  
	// 2. Timer Counter
	status = XTmrCtr_Initialize(&TimerCounterInst, TMRCTR_DEVICE_ID);
	if (status != XST_SUCCESS){
		print("Timer counter initialization failed \r\n");
		return status;
	}
	print("Timer counter initialized \r\n");


	// 3. Interrupt
  	status = XIntc_Initialize(&InterruptController, INTC_DEVICE_ID);
	print("Interrupt initialized \r\n");

	status = XIntc_Connect(&InterruptController, TMRCTR_INTERRUPT_ID,
							(XInterruptHandler)XTmrCtr_InterruptHandler,
							(void *)&TimerCounterInst);
	if (status != XST_SUCCESS){
		print("Interrupt connect failed \r\n");
		return status;
	}
	print("Interrupt set up \r\n");

	// 4. Interrupt Start
	status = XIntc_Start(&InterruptController, XIN_REAL_MODE);
	if (status != XST_SUCCESS){
		print("Interrupt start failed \r\n");
		return status;
	}
	XIntc_Enable(&InterruptController, TMRCTR_INTERRUPT_ID);
	Xil_ExceptionInit();
	Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
			 (Xil_ExceptionHandler)XIntc_InterruptHandler,
			 &InterruptController);
	Xil_ExceptionEnable();

	// 6. Timer Counter Handler
	XTmrCtr_SetHandler(&TimerCounterInst, TimerCounterHandler,
					   &TimerCounterInst);
	print("Timer counter handler set \r\n");

	// 7. Timer Options
	XTmrCtr_SetOptions(&TimerCounterInst, TIMER_CNTR_0,
					   XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION);
	print("Timer options set \r\n");
	XTmrCtr_SetResetValue(&TimerCounterInst, TIMER_CNTR_0, RESET_VALUE);
	print("Timer reset value set \r\n");

	// 8. Timer Start
	XTmrCtr_Start(&TimerCounterInst, TIMER_CNTR_0);
	print("Timer start \r\n");

	print("ALL PASS \r\n");
	while(1){
		//DO NOTHING FOR NOW
	}

    cleanup_platform();
    return 0;
}

void TimerCounterHandler(void *CallBackRef, u8 TmrCtrNumber){
	XTmrCtr *InstancePtr = (XTmrCtr *)CallBackRef;
	print("IN TIMER\r\n");
	if (XTmrCtr_IsExpired(InstancePtr, TmrCtrNumber)){
		print("Expired\r\n");
	}
}

 

But when I ran the self test after initialization of XTmrCtr, it actually does not pass the test with a status of 1 (which is indicated as failure in xstatus.h as #define XST_FAILURE   1L)

	status = XTmrCtr_SelfTest(&TimerCounterInst, TMRCTR_DEVICE_ID);
		if (status != XST_SUCCESS) {
			xil_printf("Timer self-test failed: %d \r\n", status);
			return XST_FAILURE;
		}
	print("Timer self-test pass \r\n");

 

If I understand correctly, the self-test is to check if the hardware is set up correctly.

I don't know where in the block design side is wrong. I am using following setup:

1. Clock wizard with 166.667 MHz and 200MHz

2. DDR3 SDRAM that takes in 166.667MHz as sys_clk and 200MHz as ref_clk

3. Microblaze with a separate clock [mig_7series/ui_clk (83MHz)]

4. UARTlite (interrupt connected to axi_intc via microblaze_0_xlconcat)

5. Axi Timer  (interrupt connected to axi_intc via microblaze_0_xlconcat)

 

I would appreciate your help!

Please let me know if you need any other information.

 

Thanks!

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

@jpeyron

Thank you for your response.

I apologize if I didn't make it clear.

I was looking to get timer interrupt to work not the UART interrupt.

 

I have found that self-test did not pass for the timer, which suggests that the hardware did not set up properly but I can't find where the problem is.

I followed the tutorial and just added AXI timer to the overall architecture. 

 

Thanks

Link to comment
Share on other sites

@jpeyron

I really appreciate your reply.

I actually followed the tutorial you mentioned from the beginning like you said, it uses AXI Timer.

 

I am using XTC_INT_MODE_OPTION and XTC_AUTO_RELOAD_OPTION which allows compare-mode with interrupt.

Thanks,

Penguin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...