MPLAB X DSPIC FREERTOS CRASHES

albanana wrote on Tuesday, September 02, 2014:

hello i wrote this program but i does not work, and the dspic crashes and resets periodically
i use a logic analyzer for watching the CLOCKOUT and GPIO, and the watchdog is disabled

the program counter never goes to the Blink task
but the timer 1 interrupt handler runs

did i make a mistake ? plz help!!!

THANKS :slight_smile:
sorry for the bad formatting


#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configCPU_CLOCK_HZ ( ( unsigned long ) 25000000 ) /* Fosc / 2 */
#define configMAX_PRIORITIES ( 4 )
#define configMINIMAL_STACK_SIZE ( 105 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) 5120 )
#define configMAX_TASK_NAME_LEN ( 4 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 1
#define configIDLE_SHOULD_YIELD 1

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 0
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1

#define configKERNEL_INTERRUPT_PRIORITY 0x01
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0

#endif /* FREERTOS_CONFIG_H */


#include <FreeRTOS.h>
#include <list.h>
#include <task.h>
#include <queue.h>

void vApplicationIdleHook( void )
{
for(;;){

}

}

void Blink(void * p){
// unsigned long i;

for(;;){
    LATA=0xff;
    vTaskDelay(10);
    LATA=0;
    vTaskDelay(10);
}

}

/*
*
/
int main(int argc, char
* argv) {
TRISA=0;

xTaskCreate( Blink, "Blink", configMINIMAL_STACK_SIZE , NULL, 2, NULL );
vTaskStartScheduler();
for(;;){
    
}
return 0;

}

rtel wrote on Wednesday, September 03, 2014:

crashes and resets periodically

That makes it sound like the tasks starts running, but crashes/resets after a while.

the program counter never goes to the Blink task

That makes it sound like the task never starts running at all.

So I am confused as to how far you get in your application before the problem occurs. However, do you have the MPLAB_DSPIC_PORT symbol defined in your build options to tell the pre-processor to use the dsPIC version of the code rather than the PIC24 version?

Regards.

albanana wrote on Wednesday, September 03, 2014:

okay my mistake
i declared #define MPLAB_DSPIC_PORT on top of FreeRTOSConfig.h and all works fine now.
wrong assembly code caused exception and crash at switching context time.

problem solved
THANKS

albanana wrote on Wednesday, September 03, 2014:

albanana wrote on Wednesday, September 03, 2014: