0% found this document useful (0 votes)
24 views2 pages

Ejemplo Programa 1 XC

This document contains the code for a PIC16F648A microcontroller program. It defines the oscillator frequency, configuration bits for features like the watchdog timer and programming settings. The main function configures port B with one pin as input and checks its state, turning on or off another pin on port B accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Ejemplo Programa 1 XC

This document contains the code for a PIC16F648A microcontroller program. It defines the oscillator frequency, configuration bits for features like the watchdog timer and programming settings. The main function configures port B with one pin as input and checks its state, turning on or off another pin on port B accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

/*

2. * File: main.c

3. * Author: lucas

4. * Created on 1 de abril de 2013, 22:20

5. * Microcontrolador: PIC16F648A

6. *

7. */

8.

9. #include <stdio.h>

10. #include <stdlib.h>

11. #include <xc.h> // Librera XC8

12.

13. #define _XTAL_FREQ 4000000 // Indicamos a que frecuencia de reloj esta


funcionando el micro

14.

15. // PIC16F648A Configuration Bit Settings

16. #pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTOSC


oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on
RA7/OSC1/CLKIN)

17. #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)

18. #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT
disabled)

19. #pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit
(RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
20. #pragma config BOREN = ON // Brown-out Detect Enable bit (BOD
enabled)

21. #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)

22. #pragma config CPD = OFF // Data EE Memory Code Protection bit (Data
memory code protection off)

23. #pragma config CP = OFF // Flash Program Memory Code Protection bit
(Code protection off)

24.

25. // FUNCION PRINCIPAL

26.

27. void main() {

28.

29. TRISB = 0b00000001; // Configuro puerto B

30. PORTB = 0b00000000;

31.

32. if (PORTBbits.RB0 == 1) {

33. PORTBbits.RB4 = 1;

34. } else {

35. PORTBbits.RB4 = 0;

36. }

37. }

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy