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.
//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);
Question
Tawachi
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
Archived
This topic is now archived and is closed to further replies.