Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

dspic33 - keeps rebooting

Posted by ltran2016 on February 18, 2016

I'm in the processing of bringing up the dsPIC DSC start kit and I think I have all my bases covered, but apparently that isn't the case. I've already trawled through the discussions for any issue related to this, but it hasn't helped. I'm loading a simple build that just blinks an LED periodically. The problem is it looks as if something keeps resetting the processor. I'm clearing the watchdog, but it doesn't seem to have any effect.

Could someone give this a look and tell me where I might be going wrong. I've successfully implemented FreeRTOS on NiosII, so I'm not a newbie at this.

~~~~

ifndef FREERTOSCONFIGH
define FREERTOSCONFIGH
define MPLABDSPICPORT
include
define configUSE_PREEMPTION 1
define configUSEIDLEHOOK 0
define configUSETICKHOOK 0
define configTICKRATEHZ ((TickType_t) 1000)
define configCPUCLOCKHZ ((unsigned long) 12000000) /* Fosc / 2 */
define configMAX_PRIORITIES (4)
define configMINIMALSTACKSIZE (105)
define configTOTALHEAPSIZE (( size_t ) 8192)
define configMAXTASKNAME_LEN (4)
define configUSETRACEFACILITY 0
define configUSE16BIT_TICKS 0
define configIDLESHOULDYIELD 0

/* Co-routine definitions. */

define configUSECOROUTINES 0
define configMAXCOROUTINE_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 1
define INCLUDE_vTaskDelete 1
define INCLUDE_vTaskCleanUpResources 0
define INCLUDE_vTaskSuspend 1
define INCLUDE_vTaskDelayUntil 1
define INCLUDE_vTaskDelay 1
define configKERNELINTERRUPTPRIORITY 0x01

// FBS

pragma config BWRP = WRPROTECT_OFF // Boot Segment Write Protect (Boot Segment may be written)
pragma config BSS = NO_FLASH // Boot Segment Program Flash Code Protection (No Boot program Flash segment)
pragma config RBS = NO_RAM // Boot Segment RAM Protection (No Boot RAM)

// FSS

pragma config SWRP = WRPROTECT_OFF // Secure Segment Program Write Protect (Secure Segment may be written)
pragma config SSS = NO_FLASH // Secure Segment Program Flash Code Protection (No Secure Segment)
pragma config RSS = NO_RAM // Secure Segment Data RAM Protection (No Secure RAM)

// FGS

pragma config GWRP = OFF // General Code Segment Write Protect (User program memory is not write-protected)
pragma config GSS = OFF // General Segment Code Protection (User program memory is not code-protected)

// FOSCSEL

pragma config FNOSC = FRC // Oscillator Mode (Internal Fast RC (FRC))
pragma config IESO = OFF // Two-speed Oscillator Start-Up Enable (Start up with user-selected oscillator)

// FOSC

pragma config POSCMD = NONE // Primary Oscillator Source (Primary Oscillator Disabled)
pragma config OSCIOFNC = ON // OSC2 Pin Function (OSC2 pin has digital I/O function)
pragma config FCKSM = CSDCMD // Clock Switching and Monitor (Both Clock Switching and Fail-Safe Clock Monitor are disabled)

// FWDT

pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler (1:32,768)
pragma config WDTPRE = PR128 // WDT Prescaler (1:128)
pragma config WINDIS = OFF // Watchdog Timer Window (Watchdog Timer in Non-Window mode)
pragma config FWDTEN = OFF // Watchdog Timer Enable (Watchdog timer enabled/disabled by user software)

// FPOR

pragma config FPWRT = PWR8 // POR Timer Value (8ms)

// FICD

pragma config ICS = PGD1 // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
pragma config JTAGEN = OFF // JTAG Port Enable (JTAG is Disabled)

//------------------------------------------------------------------------- LED *LEDInit (SYSINTt period, SYSINTt settaskpriority, SYSINTt clrtask_priority) { //------------------------------------------------------------------------- // allocate led space LED *pLED = (LED *)(pvPortMalloc (sizeof(LED)));

// exit if space couldn't be allocated if (pLED == NULL) return NULL;

// initialize yellow led port pin PORTBITTRI(C,13) = 0; PORTBITLAT(C,13) = 0;

// initialize red led port pin PORTBITTRI(C,14) = 0; PORTBITLAT(C,14) = 0;

// initialize green led port pin PORTBITTRI(C,15) = 0; PORTBITLAT(C,15) = 0;

// set heart beat period LEDHEARTBEATPERIOD = period;

// allocate led messeging queue, start task if queue space allocated LEDQUEUE = xQueueCreate (32, sizeof(LEDMSG)); if (LEDQUEUE != NULL) { // led gateway clear control task xTaskCreate ( LEDClrTask, "LedClear", 32, (void *)pLED, clrtask_priority, NULL); }

return pLED; }

//------------------------------------------------------------------------- static void LEDClrTask (void *pvParam) { //------------------------------------------------------------------------- //LED *pLED = (LED *)pvParam; U32 idx; portTickType xLastWakeTime;

// get initial wake count, next hearbeat time xLastWakeTime = xTaskGetTickCount (); //xHeartBeatTime = xLastWakeTime + (portTickType)LEDHEARTBEATPERIOD;

// task loop for (;;) {

  // wait 100 ticks
  vTaskDelay (100);
  // clear watchdog timer
  ClrWdt();
  PORT_BIT_LAT(C,15) = ~PORT_BIT_LAT(C,15);    // toggle pin (amber LED on demo board DM330011)

  // wait 100 ticks
  vTaskDelay (100);
  // clear watchdog timer
  ClrWdt();
  PORT_BIT_LAT(C,15) = ~PORT_BIT_LAT(C,15);

  vTaskDelayUntil (&xLastWakeTime, 300);
  // clear watchdog timer
  ClrWdt();

}

// delete task when complete vTaskDelete(NULL); } ~~~~


dspic33 - keeps rebooting

Posted by rtel on February 18, 2016

Have you tried turning the watchdog off altogether? Do you have configASSERT() defined? Is configCHECKFORSTACK_OVERFLOW set to 2?


dspic33 - keeps rebooting

Posted by ltran2016 on February 18, 2016

Thank you for the prompt response.

I think I turned off the watchdog based on the #pragma config settings, but I'm no so sure it's working. I think the watchdog can't be turned off. It can only be reset, based on what I've read from the data sheets. Don't take that as truth. I've not completely read it all yet. This is my first time dealing with this particular processor, so I'm still learning all the quirks and issues.

I have not tried configASSERT() yet. Haven't configured for overflow check either. I'll enable them and see what happens. I've run it through the hardware debugger. That's how I discovered the resetting problem.


dspic33 - keeps rebooting

Posted by ltran2016 on February 18, 2016

I figured out my problem. I wasn't allocating enough stack space to task, so I was overflowing into who knows where.


dspic33 - keeps rebooting

Posted by alainm3 on February 19, 2016

I said so... to your first post...

this is the cost common cause for that, 100% for me ;-)

Alain

On 18-02-2016 20:17, Loi Tran wrote: > > I figured out my problem. I wasn't allocating enough stack space to > task, so I was overflowing into who knows where. > > ------------------------------------------------------------------------ > > dspic33 - keeps rebooting > https://sourceforge.net/p/freertos/discussion/382005/thread/68f88dde/?limit=25#5d7d > > ------------------------------------------------------------------------ > > Sent from sourceforge.net because you indicated interest in > https://sourceforge.net/p/freertos/discussion/382005/ > > To unsubscribe from further messages, please visit > https://sourceforge.net/auth/subscriptions/ >

Attachments

alternate (1443 bytes)


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner