Microchip PIC16F628A, LED Blinking Code Using ' C ' Language, Time Delay 100 to 500 Milliseconds

Microchip PIC16F628A, LED Blinking Code Using ' C ' Language, Time Delay 100 Milliseconds
Microchip PIC16F628A, LED Blinking Code Using ' C ' Language, Time Delay 300 Milliseconds
Microchip PIC16F628A, LED Blinking Code Using ' C ' Language, Time Delay 500 Milliseconds

Microchip PIC16F628A, LED Blinking Code Using ' C ' Language, Time Delay 100 Milliseconds:

100 Millisecond Code Delay:

 * Created:   Mon Jun 8 2015
 * Processor: PIC16F628A
 * Compiler:  HI-TECH C for PIC10/12/16
 * Author:    Azhar Ahmed
 */

#include <htc.h>
//Configuration Word

__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & MCLRE_ON & BOREN_ON & LVP_OFF & CPD_OFF & CP_OFF);

//Define Pins

#define LED    RB5

//Define CPU Frequency
//This must be defined, if __delay_ms() or __delay_us() functions are used in the code

#define _XTAL_FREQ 20000000

//Main Function Start from here

void main(void)
 {
   // Write your code here
    TRISB5 = 0;                       //Make LED pin an output
    LED = 0;                            //Turn LED off        
   while (1)
   {
      LED = !LED;                //Toggle LED pin state
      __delay_ms(100);    //100 milli second delay
   }
}

Microchip PIC16F628A, LED Blinking Code Using ' C ' Language, Time Delay 300 Milliseconds:

300 Millisecond Code Delay:

 * Created:   Mon Jun 8 2015
 * Processor: PIC16F628A
 * Compiler:  HI-TECH C for PIC10/12/16
 * Author:    Azhar Ahmed
 */

#include <htc.h>
//Configuration Word

__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & MCLRE_ON & BOREN_ON & LVP_OFF & CPD_OFF & CP_OFF);

//Define Pins

#define LED    RB5

//Define CPU Frequency
//This must be defined, if __delay_ms() or __delay_us() functions are used in the code

#define _XTAL_FREQ 20000000

//Main Function Start from here

void main(void)
 {
   // Write your code here
    TRISB5 = 0;                       //Make LED pin an output
    LED = 0;                           //Turn LED off        
   while (1)
   {
      LED = !LED;                //Toggle LED pin state
      __delay_ms(300);    //300 milli second delay
   }
}

Microchip PIC16F628A, LED Blinking Code Using ' C ' Language, Time Delay 500 Milliseconds:

500 Millisecond Code Delay:

 * Created:   Mon Jun 8 2015
 * Processor: PIC16F628A
 * Compiler:  HI-TECH C for PIC10/12/16
 * Author:    Azhar Ahmed
 */

#include <htc.h>
//Configuration Word

__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & MCLRE_ON & BOREN_ON & LVP_OFF & CPD_OFF & CP_OFF);

//Define Pins

#define LED    RB5

//Define CPU Frequency
//This must be defined, if __delay_ms() or __delay_us() functions are used in the code

#define _XTAL_FREQ 20000000

//Main Function Start from here

void main(void)
 {
   // Write your code here
    TRISB5 = 0;                   //Make LED pin an output
    LED = 0;                        //Turn LED off        
   while (1)
   {
      LED = !LED;               //Toggle LED pin state
      __delay_ms(500);    //500 milli second delay
   }
}

PIC16F628A, 18-pin Flash-Based, 8-Bit CMOS Microcontrollers with nanoWatt Technology:

High-Performance RISC CPU:
  •  Operating speeds from DC – 20 MHz
  • Interrupt capability
  • 8-level deep hardware stack
  • Direct, Indirect and Relative Addressing modes
  • 35 single-word instructions:
  •  All instructions single cycle except branches
Special Microcontroller Features:
  • Internal and external oscillator options:
  •  Precision internal 4 MHz oscillator factory calibrated to ±1%
  • Low-power internal 48 kHz oscillator
  • External Oscillator support for crystals and resonators
  • Power-saving Sleep mode
  •  Programmable weak pull-ups on PORTB
  • Multiplexed Master Clear/Input-pin
  • Watchdog Timer with independent oscillator for reliable operation
  •  Low-voltage programming
  •  In-Circuit Serial Programming™ (via two pins)
  • Programmable code protection
  •  Brown-out Reset
  • Power-on Reset
  • Power-up Timer and Oscillator Start-up Timer 
  • Wide operating voltage range (2.0-5.5V)
  •  Industrial and extended temperature range
  • High-Endurance Flash/EEPROM cell:
  • 100,000 write Flash endurance
  •  1,000,000 write EEPROM endurance
  • 40 year data retention
Low-Power Features:
  • Standby Current: - 100 nA @ 2.0V, typical
  • Operating Current: - 12 μA @ 32 kHz, 2.0V, typical - 120 μA @ 1 MHz, 2.0V, typical
  • Watchdog Timer Current: - 1 μA @ 2.0V, typical
  • Timer1 Oscillator Current: - 1.2 μA @ 32 kHz, 2.0V, typical
  •  Dual-speed Internal Oscillator:
  • Run-time selectable between 4 MHz and 48 kHz
  •  4 μs wake-up from Sleep, 3.0V, typical
Peripheral Features:
  • 16 I/O pins with individual direction control
  • High current sink/source for direct LED drive
  • Analog comparator module with:
  • Two analog comparators
  • Programmable on-chip voltage reference (VREF) module
  • Selectable internal or external reference
  •  Comparator outputs are externally accessible
  • Timer0: 8-bit timer/counter with 8-bit programmable prescaler
  • Timer1: 16-bit timer/counter with external crystal/ clock capability
  • Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
  • Capture, Compare, PWM module:
  • 16-bit Capture/Compare
  • 10-bit PWM
  •  Addressable Universal Synchronous/Asynchronous Receiver/Transmitter USART/SCI

 

More From Iamtechnical.com

Advertisement:

SiteLock