Altera_Forum
Honored Contributor
8 years agoFreeRTOS on Nios II runs, but get a soft_exception after breakpoint
I am trying to implement a simple FreeRTOS V9.0 demo on my existing NiosII system. I am using FreeRTOS demo for Nios II pretty much as is. The only changes I had to do were:
- Change my BSP type to HAL
- Regenerate BSP
- Modify system.h to remove# define ALT_ENHANCED_INTERRUPT_API_PRESENT and add# define ALT_LEGACY_INTERRUPT_API_PRESENT
- Modify FreeRTOSConfig.h to match my platform settings
- Make a very simple demo (see below)
.section .exceptions.soft, "xa"soft_exceptions:
ldw et, 0(ea) # Load the instruction where the interrupt occured.
movhi at, %hi(0x003B683A) # Load the registers with the trap instruction code
ori at, at, %lo(0x003B683A)
cmpne et, et, at # Compare the trap instruction code to the last excuted instruction
beq et, r0, call_scheduler # its a trap so switchcontext
break # This is an un-implemented instruction or muldiv problem.
br restore_context # its something else static void MyTask( void *p){
static volatile u32 cntr = 0;
while(1)
{
cntr++;
vTaskDelay(100);
cntr++;
}
}
static StackType_t MyTaskStack;
StaticTask_t MyTaskBuffer;
int main()
{
TaskHandle_t taskHandle;
taskHandle = xTaskCreateStatic(
MyTask,
"MyTaskName",
NumEntries(MyTaskStack),
NULL,
2 | portPRIVILEGE_BIT, // Low priority numbers denote low priority tasks.
MyTaskStack,
&MyTaskBuffer);
if (NULL == taskHandle)
asm( "break" );
vTaskStartScheduler();
// Will only reach here if there is insufficient heap available to start the scheduler.
for( ;; );
}