Microchip PIC12F675, Three LED's Blinking, Code Using ' C ' Language, Time Delay 600 & 800 Milliseconds, 1 Second

Microchip PIC12F675, Three LED's Blinking, Code Using ' C ' Language, Time Delay 600 Millisecond
Microchip PIC12F675, Three LED's Blinking, Code Using ' C ' Language, Time Delay 800 Millisecond
Microchip PIC12F675, Three LED's Blinking, Code Using ' C ' Language, Time Delay 1 Second

Microchip PIC12F675, Three LED's Blinking, Code Using ' C ' Language, Time Delay 600 Milliseconds:

/*  Name     : pic12f675.c
 *  Purpose  : pic12f675.c file for LED blinking code for PIC12F675.
 *  Author    : Azhar Ahmed
 *  Date       : 10-06-2015
 *  Revision : None
 */
#include<htc.h>

// Config word
__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & BOREN_ON & CP_OFF & CPD_OFF);

// Define LED pin
#define LED  GP0

// 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
void main()
{    
    ANSEL  = 0x00;             // Set ports as digital I/O, not analog input
    ADCON0 = 0x00;          // Shut off the A/D Converter
    CMCON  = 0x07;          // Shut off the Comparator
    VRCON  = 0x00;         // Shut off the Voltage Reference
    TRISIO = 0x08;        // GP3 input, rest all output
    GPIO   = 0x00;        // Make all pins 0
    
    while(1)
    {
        __delay_ms(600);          // 600 Millisecond delay
        LED = 0;                        // LED off
        __delay_ms(600);       // 600 Millisecond delay
        LED = 1;                     // LED on
    }
}

Microchip PIC12F675, Three LED's Blinking, Code Using ' C ' Language, Time Delay 800 Milliseconds:

/*  Name     : pic12f675.c
 *  Purpose  : pic12f675.c file for LED blinking code for PIC12F675.
 *  Author    : Azhar Ahmed
 *  Date       : 10-06-2015
 *  Revision : None
 */
#include<htc.h>

// Config word
__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & BOREN_ON & CP_OFF & CPD_OFF);

// Define LED pin
#define LED  GP0

// 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
void main()
{    
    ANSEL  = 0x00;             // Set ports as digital I/O, not analog input
    ADCON0 = 0x00;          // Shut off the A/D Converter
    CMCON  = 0x07;          // Shut off the Comparator
    VRCON  = 0x00;         // Shut off the Voltage Reference
    TRISIO = 0x08;        // GP3 input, rest all output
    GPIO   = 0x00;        // Make all pins 0
    
    while(1)
    {
        __delay_ms(800);          // 800 Millisecond delay
        LED = 0;                        // LED off
        __delay_ms(800);       // 800 Millisecond delay
        LED = 1;                     // LED on
    }
}

Microchip PIC12F675, Three LED's Blinking, Code Using ' C ' Language, Time Delay 1 Second:

/*  Name      : pic12f675.c
 *  Purpose   : pic12f675.c file for LED blinking code for PIC12F675.
 *  Author     : Azhar Ahmed
 *  Date        : 10-06-2015
 *  Revision  : None
 */
#include<htc.h>

// Config word
__CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & BOREN_ON & CP_OFF & CPD_OFF);

// Define LED pin
#define LED  GP0

// 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
void main()
{    
    ANSEL  = 0x00;             // Set ports as digital I/O, not analog input
    ADCON0 = 0x00;          // Shut off the A/D Converter
    CMCON  = 0x07;          // Shut off the Comparator
    VRCON  = 0x00;         // Shut off the Voltage Reference
    TRISIO = 0x08;        // GP3 input, rest all output
    GPIO   = 0x00;        // Make all pins 0
    
    while(1)
    {
        __delay_ms(1000);          // 1 second delay
        LED = 0;                          // LED off
        __delay_ms(1000);       // 1 second delay
        LED = 1;                      // LED on
    }
}

Features of PIC12F675, 8-Pin Flash-Based 8-Bit CMOS Microcontroller:

High-Performance RISC CPU:
  • Only 35 Instructions to Learn
  •  All single-cycle instructions except branches
  •  Operating Speed: - DC – 20 MHz oscillator/clock input - DC – 200 ns instruction cycle
  • Interrupt Capability
  • 8-Level Deep Hardware Stack
  • Direct, Indirect, and Relative Addressing modes
Special Microcontroller Features:
  • Internal and External Oscillator Options
  • Precision Internal 4 MHz oscillator factory calibrated to ±1%
  • External Oscillator support for crystals and resonators
  • 5 micro second wake-up from Sleep, 3.0V, typical
  •  Power-Saving Sleep mode
  • Wide Operating Voltage Range – 2.0V to 5.5V
  • Industrial and Extended Temperature Range
  • Low-Power Power-on Reset (POR)
  • Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
  • Brown-out Detect (BOD)
  • Watchdog Timer (WDT) with Independent Oscillator for Reliable Operation
  •  Multiplexed MCLR/Input Pin
  •  Interrupt-on-Pin Change
  •  Individual Programmable Weak Pull-ups
  • Programmable Code Protection
  •  High Endurance Flash/EEPROM Cell
  • 100,000 write Flash endurance
  • 1,000,000 write EEPROM endurance
  • Flash/Data EEPROM Retention: > 40 years
Low-Power Features:
  • Standby Current: - 1 nA @ 2.0V, typical
  • Operating Current: - 8.5 micro A @ 32 kHz, 2.0V, typical - 100 micro A @ 1 MHz, 2.0V, typical
  • Watchdog Timer Current - 300 nA @ 2.0V, typical
  • Timer1 Oscillator Current: - 4 micro A @ 32 kHz, 2.0V, typical
Peripheral Features:
  • 6 I/O Pins with Individual Direction Control
  • High Current Sink/Source for Direct LED Drive
  • Analog Comparator module:
  • One analog comparator
  • Programmable on-chip comparator voltage reference (CVREF) module
  • Programmable input multiplexing from device inputs
  • Comparator output is externally accessible
  • Analog-to-Digital Converter module (PIC12F675)
  •  10-bit resolution
  • Programmable 4-channel input
  • Voltage reference input
  • Timer0: 8-Bit Timer/Counter with 8-Bit Programmable Prescaler
  • Enhanced Timer1:
  • 16-bit timer/counter with prescaler
  • External Gate Input mode
  • Option to use OSC1 and OSC2 in LP mode as Timer1 oscillator, if INTOSC mode selected
  • In-Circuit Serial Programming (ICSP) via two pins

 

More From Iamtechnical.com

Advertisement:

SiteLock