-->

MPLAB XC8 Compiler – LED Blinking - Basic Start-up Tutorials

By
A sample program to blink an LED  by using MPLBX - C Compilers  in  PIC16F877A as our previous post  PIC Microcontroller Tutorial gives the basic Details of PIC16f877A.

           In MPLABX  at first we need to configure the bit first.  That means ,


  •  How or what type Oscillator will use  ?
  •  Is there needed Watch Dog timer ?
  •  Program Memory Code Protection bit ie, no one can be read the HEX code from  the Controller.

      For more learn from Here.

#include<xc.h> 
// CONFIG
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = ON // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)


#define _XTAL_FREQ 8000000 // taking as crystal frequency as 8Mhz
#define LED_Port PORTD // defining PORTD as LED_Port
int main()
{
TRISD = 0x00; // Making PORTD as output
while(1)
{
LED_Port =0Xff; // giving High values to Port to lightup LED
__delay_ms(500); // giving a half second delay
LED_Port = 0x00; // Giving a low to port to turn off the LEDs
__delay_ms(500);
}

}

More Posts

gElectron. Powered by Blogger.

Contributors

16x2 LCD Interfacing with STM32,STM32F103C6

 16x2 LCD  Interfacing with STM32,STM32F103C6 lcd_init(); LCD_LINE1; lcd_String(" GeElectron"); LCD_LINE2; lc...

Contact Form

Name

Email *

Message *

Contact us

Name

Email *

Message *

Follow Us

https://www.facebook.com/gElectron-393939667321867/ FBbox/https://www.facebook.com/IVYthemes

Comments

[blogger]

MKRdezign

Test
google.com, pub-8429441124104529, DIRECT, f08c47fec0942fa0
[blogger]

Latest

[recent][newsticker]

Technology

Top Ads

RECENT COMMENTS

Subscribe Via Email

Subscribe to our newsletter to get the latest updates to your inbox. ;-)


Your email address is safe with us!

RECENT COMMENTS