Hello Ben,
zeig bitte dein config und includes, bzw prüfe dies selbst.
Die _delay*XY() funktionen sind Macros die davon leben das DU
den Systemtakt richtig eingestellt bzw bekannt gegeben hast.
Ohne diese werte kommt nix gutes raus, wenn es denn überhaupt
compiliert.
ie:
// PIC18F4520 Configuration Bit Settings
#include <xc.h> <= wichtig
// CONFIG1H
#pragma config OSC = INTIO67 // Oscillator Selection bits (Internal
oscillator block, port function on RA6 and RA7)
...
#define FOSC 32000000UL // 32mhz -> befehlstakt -> 8mhz cycle
freq
#define FCY FOSC / 4UL // Cycle Frequenz
#define XTAL_FREQ 32000000UL // <== WICHTIG FÜR delay.h und xc.8 libs
!!
#define BAUDRATE 19200UL
#define BRG (( FCY 16 BAUDRATE ) -1UL)
#include <delays.h> <= und hier der wichtigste!!
...
erst XTAL_FREQ definieren, DANN der include <delays.h>
siehe "help" in mplabx, suchwort _delay und dann xc8 waehlen falls du
ander compiler auch installiert hast.
solle so aehnlich in der hilfe sein:
As it is often more convenient request a delay in time-based terms
rather than in cycle
counts, the macros __delay_ms(x) and __delay_us(x) are provided. These
macros simply wrap around _delay(n) and convert the time based request
into instruction cycles based on the system frequency. In order to
achieve this, these macros require the prior definition of preprocessor
symbol _XTAL_FREQ. This symbol should be defined as the oscillator
frequency (in Hertz) used by the system.
mfG
Peter