Im sure Im missing something simple, and obvious, but I am tired of searching for the answer. Im using a PIC16F688
and XC8
compiler.
The compiler user manual says that there is a delay function __delay_ms()
. It says that _XTAL_FREQ
must be defined.
Here is my code, but it does not accept the command. What is wrong?
#include <stdio.h>
#include <stdlib.h>
#define _XTAL_FREQ 20000000
#include<xc.h>
int main(int argc, char** argv) {
_delay_ms(4);
return (EXIT_SUCCESS);
They are right, the problem was experienced by older versions of the IDE's. I have found it helpful to use:
while(1){
//Invert LED state
LED = !LED;
//Delay ~1 second (4MHz Internal Clock)
_delay(1000000); //specify clock cycles directly
}
To solve the problem.