Hi,
I have implemented a Microblaze v7.00.b with EDK 9.2 on a Virtex 4 fx12. A timer (xps_timer v1.00.a) generates an interrupt which is relayed by an interrupt controller (xps_intc v1.00.a) to the interrupt pin of the Microblaze. The code uses the standalone library.
The piece of code that handles this interrupt only increment a variable and display it using "xil_printf" instruction.
If i put an infinite loop "while(1)", at the end of the initialisation of the timer and the interrupt controller, the interrupt is normaly handled each time it occurs unless there is a rand() or srand() instruction in the code just before the "while(1)". When a rand() or srand() instruction is used, the interrupt that occurs just after is not handled, the microblaze is then frozen and a reset does not allow to re-run the programm as if it has been corrupted.
The code of the handler:
void TimerCounterHandler(void *CallBackRef, Xuint8 TmrCtrNumber) { Counter +=3D 1; xil_printf("\r\ntime: %d s",Counter); }
The setup of the timer and the interrupt controller:
XStatus Status;
//Initialize the timer counter Status =3D XTmrCtr_Initialize(&my_timer, TIMER_DEVICE_ID);
//Initialize the interrupt controller driver Status =3D XIntc_Initialize(&my_int_controller, INTC_DEVICE_ID);
//Connect the interrupt controller to the timer Status =3D XIntc_Connect( &my_int_controller, TIMER_INTERRUPT_ID, (XInterruptHandler)XTmrCtr_InterruptHandler, (void *)&my_timer);
//Start the interrupt controller in real mode Status =3D XIntc_Start(&my_int_controller, XIN_REAL_MODE);
//Enable the interrupt for the timer XIntc_Enable(&my_int_controller, INTC_DEVICE_ID);
//Enable the interrupts on the Microblaze microblaze_enable_interrupts();
//Set the handler to call when the timer is expired XTmrCtr_SetHandler( &my_timer, TimerCounterHandler, &my_timer);
//set the timer to autoreload mode and decreasing mode (increase is the default mode) XTmrCtr_SetOptions( &my_timer, TIMER_NBR_0, XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION );
XTmrCtr_SetResetValue( &my_timer, TIMER_NBR_0, RESET_VALUE);
//Start the timer counter XTmrCtr_Start( &my_timer,TIMER_NBR_0);
/**********************************
* * this one works ***********************************/ //int i; //i =3D rand()%1000; while(1) { // the interrupt occurs and is handled.}
/**********************************
* * this one does not work ***********************************/ int i; i =3D rand()%1000; while(1) { // freeze of the microblaze when the interrupt occurs. }Regards,
R=E9my