cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
s_zo
Observer
Observer
4,524 Views
Registered: ‎01-05-2016

ERROR: Unable to Stop Processor. System could be in unknown state. Please reset the system

Hi 

I realized a design bazed on arm processor and two axi timers on zc702 board and I succeed to generate the bitstreamSans titre.png

I realised a software program using FreeRTOS operating system (in SDK) to communicate with the two timers, but when I load the .elf file I can't see anything in Tera Term and when I use the command "stop" to stop the processor this error busts: ERROR: Unable to Stop Processor. System could be in unknown state. Please reset the system

 

What should I do please, I'm really stuck here

this is my code bellow, help please,

 

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

/* Standard includes. */
#include <string.h>
#include <stdio.h>


/* BSP includes. */
#include "xtmrctr.h"
#include "xil_exception.h"
#include "xscugic.h"

/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "timers.h"

/* Xilinx includes. */
#include "xil_printf.h"
#include "xparameters.h"
#include "xil_types.h"
#include "xtmrctr.h"
#include "xscugic.h"

/***********************************************************************/
xTaskHandle TaskHandle_1;
xTaskHandle TaskHandle_2;

static void vTask1( void *pvParameters );
static void vTask2( void *pvParameters );

#define XPAR_FABRIC_TMRCTR_0_VEC_ID 0x0E
#define XPAR_FABRIC_TMRCTR_1_VEC_ID 0x0F

// Change this value to make timer interrupts more or less frequent
#define TIMER0_DURATION 5000000
#define TIMER1_DURATION 5000000

// Function Prototypes
void TimerISR();
int SetUpInterruptSystem(XScuGic *XScuGicInstancePtr);
int InitInterrupts();

// Global Variables
XScuGic InterruptController; /* Instance of the Interrupt Controller */
XScuGic_Config *GicConfig; /* The configuration parameters of the controller */
XTmrCtr Timer0; /* Instance of the Timer0 */
XTmrCtr Timer1; /* Instance of the Timer1 */


volatile unsigned char timer0Flag = 0;
volatile unsigned char timer1Flag = 0;

// Timer interrupt service routine
void Timer0ISR()
{
timer0Flag = 1;
// Clear interrupt status bit in control register
XTmrCtr_SetControlStatusReg(XPAR_AXI_TIMER_0_BASEADDR, 0, XTmrCtr_GetControlStatusReg(XPAR_AXI_TIMER_0_BASEADDR, 0));
}

void Timer1ISR()
{
timer1Flag = 1;
// Clear interrupt status bit in control register
XTmrCtr_SetControlStatusReg(XPAR_AXI_TIMER_1_BASEADDR, 0, XTmrCtr_GetControlStatusReg(XPAR_AXI_TIMER_1_BASEADDR, 0));
}

/******************************************************************************/
/**
*
* This function connects the interrupt handler of the interrupt controller to
* the processor. This function is seperate to allow it to be customized for
* each application. Each processor or RTOS may require unique processing to
* connect the interrupt handler.
*
* @param XScuGicInstancePtr is the instance of the interrupt controller
* that needs to be worked on.
*
* @return None.
*
* @note None.
*
****************************************************************************/
int SetUpInterruptSystem(XScuGic *XScuGicInstancePtr)
{

/*
* Connect the interrupt controller interrupt handler to the hardware
* interrupt handling logic in the ARM processor.
*/
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler) XScuGic_InterruptHandler, XScuGicInstancePtr);

/*
* Enable interrupts in the ARM
*/
Xil_ExceptionEnable();

return XST_SUCCESS;
}

int InitInterrupts()
{
int Status;

/*
* Initialize the interrupt controller driver so that it is ready to
* use.
*/
GicConfig = XScuGic_LookupConfig(XPAR_PS7_SCUGIC_0_DEVICE_ID);
if (NULL == GicConfig) {
return XST_FAILURE;
}

Status = XScuGic_CfgInitialize(&InterruptController, GicConfig, GicConfig->CpuBaseAddress);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}

/*
* Setup the Interrupt System
*/
Status = SetUpInterruptSystem(&InterruptController);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}

/*
* Connect a device driver handler that will be called when an
* interrupt for the device occurs, the device driver handler performs
* the specific interrupt processing for the device
*/

Status = XScuGic_Connect(&InterruptController, XPAR_FABRIC_TMRCTR_0_VEC_ID, (Xil_ExceptionHandler)Timer0ISR, &Timer0);
Status = XScuGic_Connect(&InterruptController, XPAR_FABRIC_TMRCTR_1_VEC_ID, (Xil_ExceptionHandler)Timer1ISR, &Timer1);

if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
// Enable the interrupt
XScuGic_Enable(&InterruptController, XPAR_FABRIC_TMRCTR_0_VEC_ID);
XScuGic_Enable(&InterruptController, XPAR_FABRIC_TMRCTR_1_VEC_ID);
return XST_SUCCESS;
}

/*-----------------------------------------------------------*/

int main( void )
{
//init_platform();

int xStatus;

/***AXI Timer0 Initialization****/

xStatus = XTmrCtr_Initialize(&Timer0,XPAR_AXI_TIMER_0_DEVICE_ID);
if(XST_SUCCESS != xStatus)
print("TIMER0 INIT FAILED \n\r");


/***AXI Timer1 Initialization****/
xStatus = XTmrCtr_Initialize(&Timer1,XPAR_AXI_TIMER_1_DEVICE_ID);
if(XST_SUCCESS != xStatus)
print("TIMER1 INIT FAILED \n\r");

/***Setting timer0 and timer1 Reset Value***/

XTmrCtr_SetResetValue(&Timer0, XPAR_AXI_TIMER_0_DEVICE_ID, TIMER0_DURATION);
XTmrCtr_SetResetValue(&Timer1, XPAR_AXI_TIMER_1_DEVICE_ID, TIMER1_DURATION);

/***Setting timer0 and timer1 Option (Interrupt Mode, Auto Reload, Down Count )**/

XTmrCtr_SetOptions(&Timer0, XPAR_AXI_TIMER_0_DEVICE_ID,(XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_DOWN_COUNT_OPTION));
XTmrCtr_SetOptions(&Timer1, XPAR_AXI_TIMER_1_DEVICE_ID,(XTC_INT_MODE_OPTION | XTC_AUTO_RELOAD_OPTION | XTC_DOWN_COUNT_OPTION));


/*****Interrupt controller initialization*****/

xStatus = InitInterrupts();
if(XST_SUCCESS != xStatus)
print("INTERRUPT INIT FAILED \n\r");

/****Start the timer0 and timer1****/
XTmrCtr_Start(&Timer0, XPAR_AXI_TIMER_0_DEVICE_ID);
XTmrCtr_Start(&Timer1, XPAR_AXI_TIMER_1_DEVICE_ID);

/* Create one of the two tasks. Note that a real application should check
the return value of the xTaskCreate() call to ensure the task was created
successfully. */

xTaskCreate( vTask1, /* Pointer to the function that implements the task. */
"Task 1",/* Text name for the task. This is to facilitate debugging only. */
configMINIMAL_STACK_SIZE, /* Stack depth - most small microcontrollers will use much less stack than this. */
NULL, /* We are not using the task parameter. */
tskIDLE_PRIORITY+1, /* This task will run at priority 1. */
TaskHandle_1 ); /* We are going to use the task handle. */

/* Create the other task in exactly the same way and at the same priority. */
xTaskCreate( vTask2, "Task 2", configMINIMAL_STACK_SIZE, NULL,tskIDLE_PRIORITY+2, TaskHandle_2 );

 


/* Waiting Timer0 to be expired then resume task 0**************************/
if (XTmrCtr_IsExpired(&Timer0, 0))
{
timer0Flag=1;
/* If timer0 expires change state from suspended to ready*/
vTaskResume(TaskHandle_1);
}

/* Waiting Timer1 to be expired then resume task 1**************************/
if (XTmrCtr_IsExpired(&Timer1, 0))
{
timer1Flag=1;
/* If timer1 expires change state from suspended to ready*/
vTaskResume(TaskHandle_2);
}


/* Start the scheduler so the tasks start executing. */
vTaskStartScheduler();
xil_printf("Timer");
/* If all is well then main() will never reach here as the scheduler will
now be running the tasks. If main() does reach here then it is likely that
there was insufficient heap memory available for the idle task to be created.
CHAPTER 5 provides more information on memory management. */

/* If all is well then the following line will never be reached. If
execution does reach here, then it is highly probably that the heap size
is too small for the idle and/or timer tasks to be created within
vTaskStartScheduler(). */
taskDISABLE_INTERRUPTS();
for( ;; );
}

/*-----------------------------------------------------------*/
void vTask1( void *pvParameters )
{
const char *pcTaskName = "Task 1 is running\r\n";


/* As per most tasks, this task is implemented in an infinite loop. */
for( ;; )
{
/* Print out the name of this task. */
xil_printf( pcTaskName );

/* Suspend the task. */
vTaskSuspend(TaskHandle_1);
}
}

/*-----------------------------------------------------------*/
void vTask2( void *pvParameters )
{
const char *pcTaskName = "Task 2 is running\r\n";


/* As per most tasks, this task is implemented in an infinite loop. */
for( ;; )
{

/* Print out the name of this task. */
xil_printf( pcTaskName );

/* Suspend the task. */
vTaskSuspend(TaskHandle_2);
}
}

/*-----------------------------------------------------------*/

 

0 Kudos
0 Replies