Skip to content

Instantly share code, notes, and snippets.

@davilamds
Created July 10, 2014 03:56
Show Gist options
  • Save davilamds/6128dea86f325f68628e to your computer and use it in GitHub Desktop.
Save davilamds/6128dea86f325f68628e to your computer and use it in GitHub Desktop.
holamundoXC8
/*
* File: hmheader.h
* Author: MIGUEL
*
* Created on 9 de julio de 2014, 10:07 p.m.
*/
// PIC16F628A Configuration Bit Settings
// 'C' source line config statements
#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 = INTOSCIO // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
#pragma config BOREN = ON // Brown-out Detect Enable bit (BOD enabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
/*
* File: hmmain.c
* Author: MIGUEL
*
* Created on 9 de julio de 2014, 10:28 p.m.
*/
#include <stdio.h>
#include <stdlib.h>
#include "hmheader.h"
#define _XTAL_FREQ 4000000 // se define la frecuencia del cristal para los retardos
/*==============================================================================
Inicializar puertos, esta función es llamada luego en el main().
==============================================================================*/
void initPorts(void)
{
TRISB = 0b00000000; // Todo el puerto B es salida
PORTB = 0; // Se apaga todo el puerto B
}
/*==============================================================================
Bucle principal
==============================================================================*/
int main(void)
{
// Inicializar puertos y periféricos
initPorts();
// Repetir indefinidamente
while(1)
{
// prender puerto B
PORTB = 0b11111111;
_delay(1000000); //retardo de 1 millón de pulsos de reloj
// apagar puerto b
PORTB = 0b00000000;
_delay(1000000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment