I'm new to mplab and xc8.. my codes works fine except for the delay, here are my codes..
i want to blink an led for 1 sec but it blinks greater than the delay i want..any help would be appreciated,,Thank you
Moderators note: Please use code tags for pieces of code
Code:
#include<pic.h>
#include "PIC16F84A.h"
/*
#include <xc.h>
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
// CONFIG
#pragma config FOSC = XT // Oscillator Selection bits (XT oscillator)
#pragma config WDTE = OFF // Watchdog Timer (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (Power-up Timer is disabled)
#pragma config CP = OFF // Code Protection bit (Code protection disabled)
#define _XTAL_FREQ 4000000*/
void delay(){
for(int i = 0;i<20;i++)
__delay_ms(50);
;
}
void main(){
TRISB&=~0x01;
PORTB&=~0x01;
while(1){
RB0=~RB0;
delay();
}
}
Moderators note: Please use code tags for pieces of code
Last edited by a moderator: