Creating a simple task with dspic33FJ16GS504

kramema24 wrote on Wednesday, November 08, 2017:

#include <stdio.h>
#include <stdlib.h>
#include <p33Fxxxx.h>
#include <libpic30.h>

 int FBS __attribute__((space(prog), address(0xF80000))) = 0xFFFF ;
//    BWRP_WRPROTECT_OFF & // Boot Segment Write Protect (Boot Segment may be written)
//    BSS_NO_FLASH         // Boot Segment Program Flash Code Protection (No Boot program Flash segment)
 int FGS __attribute__((space(prog), address(0xF80004))) = 0xFFFF ;
//    GWRP_OFF &           // General Code Segment Write Protect (General Segment may be written)
//    GSS_OFF              // General Segment Code Protection (User program memory is not code-protected)
 int FOSCSEL __attribute__((space(prog), address(0xF80006))) = 0xFFFF ;
//    FNOSC_FRCDIVN &      // Oscillator Source Selection (Internal Fast RC (FRC) oscillator with postscaler)
//    IESO_ON              // Internal External Switch Over Mode (Start up device with FRC, then automatically switch to user-selected oscillator source)
 int FOSC __attribute__((space(prog), address(0xF80008))) = 0xFFFF ;
//    POSCMD_NONE &        // Primary Oscillator Source (Primary oscillator disabled)
//    OSCIOFNC_OFF &       // OSC2 Pin Function (OSC2 is clock output)
//    IOL1WAY_ON &         // Peripheral Pin Select Configuration (Allow only one reconfiguration)
//    FCKSM_CSDCMD         // Clock Switching and Monitor (Clock switching and Fail-Safe Clock Monitor are disabled, Mon Disabled)
 int FWDT __attribute__((space(prog), address(0xF8000A))) = 0xFFFF ;
//    WDTPOST_PS32768 &    // Watchdog Timer Postscaler (1:32,768)
//    WDTPRE_PR128 &       // WDT Prescaler (1:128)
//    WINDIS_OFF &         // Watchdog Timer Window (Watchdog Timer in Non-Window mode)
//    FWDTEN_ON            // Watchdog Timer Enable (Watchdog timer always enabled)
 int FPOR __attribute__((space(prog), address(0xF8000C))) = 0xFFFF ;
//    FPWRT_PWR128         // POR Timer Value (128ms)
 int FICD __attribute__((space(prog), address(0xF8000E))) = 0xFFDF ;
//    ICS_PGD1 &           // Comm Channel Select (Communicate on PGC1/EMUC1 and PGD1/EMUD1)
//    JTAGEN_OFF           // JTAG Port Enable (JTAG is disabled)

static void vCheckTask( void *pvParameters );

int main(void) {
    TRISA = 0x0000;
    TRISB = 0x0000;
    LATA = 0x0000;
    LATB = 0x0000;
    xTaskCreate( vCheckTask, "Check", 105 * 2, NULL, 3, NULL );

	/* Start the task that will control the LCD.  This returns the handle
	to the queue used to write text out to the task. */
	/* Finally start the scheduler. */

static void vCheckTask( void *pvParameters )
    while(1) {
        LATA = 0xFFFF;
        LATB = 0xFFFF;


Ive been working on this for 2 days now. Im usingf ree RTOS because its need for our project. I dont have any background on RTOS. Ive succesfuly build the program and uploaded it to the controller but the LEDs does not turn on. I badly need your help

rtel wrote on Wednesday, November 08, 2017:

Not enough information to be able to help. Step into the vTaskStartScheduler function in the debugger to see how far it gets. Does the first task start? If you have a breakpoint in the first task, is it hit?

kramema24 wrote on Wednesday, November 08, 2017:

im so sorry sir, im so noob, im using MPLABX to code this. how do i know if the first task has started, and how do i go vTaskStartScheduler using the debugger?

kramema24 wrote on Wednesday, November 08, 2017:

sir can I give you my source code?

kramema24 wrote on Wednesday, November 08, 2017:

sir can I give you my source code?

tlafleur wrote on Wednesday, November 08, 2017:

I would suggest that you build and test the version of FreeRTOS from the demo site below on Microchip demo hardware to get familiar with FreeRTOS… then, upgrade the files to current version 9.x of FreeRTOS… then port to your specific 33FJ16GS504 hardware.

The dsPIC33FJ16GS504 is very limited in ram and flash memory and may not be the best candidate for using FreeRTOS without very careful attention to ram and flash usage…

~~ _/) _/) _/) ``` _/) ~~

Tom Lafleur

On Nov 7, 2017, at 11:55 PM, Mark Lexther Ame wrote:

sir can I give you my source code?

Creating a simple task with dspic33FCreating a simple task with dspic33FJ16GS504J16GS504

Sent from because you indicated interest in

To unsubscribe from further messages, please visit