16f628a_ej_data

Upload: carlos-geovanni-valladares-henriquez

Post on 01-Mar-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 16f628a_ej_data

    1/2

    #include 02.03.#FUSES NOWDT //No Watch Dog Timer04.#FUSES INTRC_IO //Internal RC Osc05.#FUSES NOPUT //No Power Up Timer06.#FUSES NOPROTECT //Code not protected from reading07.#FUSES NOBROWNOUT //No brownout reset

    08.#FUSES NOMCLR //Master Clear pin used for I/O09.#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O10.#FUSES NOCPD //No EE protection11.#FUSES RESERVED //Used to set the reserved FUSE bits12.13.#use delay(clock=4000000)14.#use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,STREAM=BLUE,errors)

    #include "conf.h"02.#include

    03.04.//direccin del registro TRISA05.#byte TRISA = 8506.07.//direccin del puerto A08.#byte puerto_a = 0509.#bit RA0 = puerto_a.010.11.12.#int_RDA13.//Cuando entra un mensaje se produce una interrupcin14.void RDA_isr(void) {15.

    16. char entrada[5]="\0";17.18. //Guardamos el mensaje recibido19. fgets(entrada,BLUE);20.21. char led1[3]="\0";22. char led2[3]="\0";23.24. led1="1";25. led2="2";26.27. //Comparamos el mensajes recibido para saber que hacer:

    28.29. if(strcmp(entrada,led1)==0)RA0=0; //ON30. else if(strcmp(entrada,led2)==0)RA0=1;//OFF31. else {32. int i;33. for( i=1; i

  • 7/25/2019 16f628a_ej_data

    2/2

    44. setup_comparator(NC_NC_NC_NC);45. setup_vref(FALSE);46.47. //Activamos las interrupciones48. enable_interrupts(INT_RDA);49. enable_interrupts(GLOBAL);50.

    51. //configuramos el puerto A52. set_tris_a( 0xfe);53. puerto_a =0x01;54.55. putc('Z');56.57. //como el mensaje produce una interrupcin, el resto del tiempo estamos enun bucle infinito sin hacer nada58. while(true){59.60. }61. }