Jump to content
  • 0

main.c:35: undefined reference to `__delay_ms'


Tawachi

Question

Hi,

When I try to use the delay function (__delay_ms() in a simple code for turning LEDs on and off, the project does not build. I have defined _XTAL_FREQ as indicated in MPLABX help. When I include 'delays.h' as indicated in the help, I get a parse error. When I try to build without including delays.h I get the error below. Are the delay functions not available foe PIC32MZ devices? I am using Flow Cloud Skeleton App, and the device is PIC32MZ2048ECG100 ChipKit WiFire. Below is the error and the code.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Error:

c:/microchip/harmony/current/apps/flow/flow_skeletonapp/src/main.c:35: undefined reference to `__delay_us'

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Code:

#include <stddef.h>                     // Defines NULL
#include <stdbool.h>                    // Defines true
#include <stdlib.h>                     // Defines EXIT_FAILURE
#include <system/debug/sys_debug.h>
#include <tcpip/src/system/system_debug.h>
#include <app_core.h>

#include "app.h"
#include "command_handlers.h"

#define _XTAL_FREQ=200000000;

//App information given to libappbase.
static APP_info info =
{
    .appName = "Flow PIC32MZ WiFire Skeleton App",
    .appVersion = "1.0.0",
    .appVersionDate =  "23 Mar 2015",
    .AppTask = SYS_AppTask,
    .CommandSet = CommandSet,
    .CommandShow = CommandShow,
    .AppCLI_ResetHandler = CommandHandlers_ResetHandler
};
//char message [200];

int main ( void )
{
    //libappbase inits and then runs our task.
    
    TRISE=0; //set all pins as outputs
    ANSELE=0; //set all 8 pins as digital
    while(1){
        PORTE=0x00ff; //set all 8 pins to HIGH
        __delay_ms(100);
        PORTE=0x0000; //set all pins to LOW
        __delay_ms(100);
    }  
    return APPCORE_init(&info);
       
}

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Hi,

After doing some searching the delay functions (such as __delay_ms() ) were native to XC8, but I don't know if they are also native to Harmony. You could try using some of the delay's suggested here and here on the microchip forums, or try the timer service library that comes with the system service library for Harmony (documentation tab, system service library, use the "control find" function with "delay" as your search term in the document)

Let me know if you have any more questions.

Thanks,
JColvin

Link to comment
Share on other sites

Hi JColvin,

Thank you for your response. I looked at the delay functions suggested on microchip forums. However, when I use the code, my ide is unable to resolve most functions such as readcoretimer. I also looked at the Harmony time system service, which requires the include header files sys.h and sys_tmr.h, but when I include these files, the ide parse utility says it cannot find these include files. I don't know whether its related to my version. I am using MPLAB X IDE version 3 and Harmony version 1.03. I will try to use free RTOS delay function or using Flow cloud library core functions.

Regards,

Tawachi

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...