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: 
Visitor junxiu6
Visitor
4,193 Views
Registered: ‎04-29-2008

Timer ISR written in C++ can not be found?

The opb timer and intc are added into the system, and the correlative defination is shown as following. The application is written in C++. And when build the project, it says that "microblaze_register_handler" is not declared and undefined reference to `timer_rev_handler'. But, i have include the <xtmrctr.h> and write the timer ISR.

 

Is the ISR cann't be written in CPP? thanks a lot.

 

MHS file:

BEGIN opb_intc
 PARAMETER INSTANCE = opb_intc_0
 PARAMETER HW_VER = 1.00.c
 PARAMETER C_BASEADDR = 0x41200000
 PARAMETER C_HIGHADDR = 0x4120ffff
 BUS_INTERFACE SOPB = mb_opb
 PORT Irq = Interrupt
 PORT Intr = RS232_Uart_1_Interrupt & SysACE_CompactFlash_SysACE_IRQ & opb_timer_1_Interrupt
END

 

BEGIN opb_timer
 PARAMETER INSTANCE = opb_timer_1
 PARAMETER HW_VER = 1.00.b
 PARAMETER C_COUNT_WIDTH = 32
 PARAMETER C_ONE_TIMER_ONLY = 1
 PARAMETER C_BASEADDR = 0x41c00000
 PARAMETER C_HIGHADDR = 0x41c0ffff
 BUS_INTERFACE SOPB = mb_opb
 PORT Interrupt = opb_timer_1_Interrupt
 PORT CaptureTrig0 = net_gnd
END

 

MSS file:

BEGIN DRIVER
 PARAMETER DRIVER_NAME = tmrctr
 PARAMETER DRIVER_VER = 1.00.b
 PARAMETER HW_INSTANCE = opb_timer_1
 PARAMETER int_handler = timer_rev_handler, int_port = Interrupt
END

 

The application file(CPP) :

void timer_rev_handler(void * baseaddr_p) {
 unsigned int csr;
 csr = XTmrCtr_mGetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0);
 if( csr & XTC_CSR_INT_OCCURED_MASK ) {
  count++;
 }
 XTmrCtr_mSetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0, csr);
}

 

int main ()
{
 int i;
  microblaze_register_handler( (XExceptionHandler)timer_rev_handler, (void *)XPAR_OPB_TIMER_1_BASEADDR);
  XIntc_mMasterEnable(XPAR_OPB_INTC_0_BASEADDR);
  XIntc_mEnableIntr(XPAR_OPB_INTC_0_BASEADDR, 0x1);
  XTmrCtr_mSetLoadReg(XPAR_OPB_TIMER_1_BASEADDR, 0, (timer_count*timer_count+1) * 80000000);
  XTmrCtr_mSetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK );
  XIntc_mEnableIntr(XPAR_OPB_TIMER_1_BASEADDR, XPAR_OPB_TIMER_1_INTERRUPT_MASK);
  XTmrCtr_mSetControlStatusReg(XPAR_OPB_TIMER_1_BASEADDR, 0, XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK |
        XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK); 
  microblaze_enable_interrupts();
   
  TheFunction();
 
 xil_printf("the count is %d, the timer register is %d\r\n", count, XTmrCtr_mGetTimerCounterReg(XPAR_OPB_TIMER_1_BASEADDR,0));
 print("Quit the main funciton\r\n");
}

Message Edited by junxiu6 on 06-04-2009 02:34 AM
Tags (2)
0 Kudos
2 Replies
Xilinx Employee
Xilinx Employee
4,151 Views
Registered: ‎08-07-2007

Re: Timer ISR written in C++ can not be found?

To use the microblaze_register_handler() function, you need to include mb_interface.h file.

 

-XF

0 Kudos
Highlighted
Visitor junxiu6
Visitor
4,121 Views
Registered: ‎04-29-2008

Re: Timer ISR written in C++ can not be found?

#include <mb_interface.h> is added,but it is still not running. the error is as following:

 

------


**** Incremental build of configuration Debug for project gauseEdedgeTimer ****

make all
mb-g++ -c -mno-xl-soft-mul -mxl-pattern-compare -mcpu=v6.00.b -I../../microblaze_0_sw_platform/microblaze_0/include -xl-mode-executable -g -O0 -oimageprocess.o ../imageprocess.cpp
 
mb-g++ -c -mno-xl-soft-mul -mxl-pattern-compare -mcpu=v6.00.b -I../../microblaze_0_sw_platform/microblaze_0/include -xl-mode-executable -g -O0 -omain.o ../main.cpp
../main.cpp:50:2: warning: no newline at end of file
 
Building target: gauseEdedgeTimer.elf
mb-g++ -o gauseEdedgeTimer.elf imageprocess.o main.o    -mno-xl-soft-mul -mxl-pattern-compare -mcpu=v6.00.b  -L../../microblaze_0_sw_platform/microblaze_0/lib -xl-mode-executable  
../../microblaze_0_sw_platform/microblaze_0/lib/libxil.a(xintc_g.o)(.data+0x10):/cygdrive/d/work/xilinx_xps/SDK_projects/microblaze_0_sw_platform/microblaze_0/libsrc/intc_v1_00_c/src/xintc_g.c: undefined reference to `timer_rev_handler'
collect2: ld returned 1 exit status
make: *** [Timer.elf] Error 1
Build complete for project Timer

0 Kudos