12F1822 example using Hi-Tech C

Example code for Microchip 12F1822 using Hi-Tech C Compiler

Flashes LED on RA5 every second

#include    <htc.h>

/*
 *    Hi-Tech C Demo program for 12F1822
 *
 *    Flashes LED on Port A (RA5) every second
 *
 *    Copyright (C)2011 HobbyTronics.co.uk
 *    Freely distributable.
 */

// Config MCLR Enabled, Code Protect on, Watchdog disabled
// Brownout off, Internal Osc

__CONFIG(MCLRE_ON & CP_ON & WDTE_OFF & BOREN_OFF & FOSC_INTOSC);

#define _XTAL_FREQ 16000000            // Used in __delay_ms() functions

main(void)
{
    unsigned char i;

    TRISA = 0b000000;       // all bits output
    OSCCON = 0b01111010;    // set internal osc to 16MHz
    for(;;) {
        RA5 = 1;            // LED ON
        __delay_ms(500);    // delay 500ms

        RA5 = 0;            // LED OFF
        __delay_ms(500);    // delay 500ms
    }
}
Shopping Cart
0 items
 
DELIVERY/PAYMENT

Free Delivery Orders over £50

UK - £2.40 orders under £50
Airmail from £2.95 (+VAT)
More Details...

 
Brands
 
 Check out our videos
Follow us on:
acebook