Guest User

Untitled

a guest
Dec 12th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. #define _XTAL_FREQ 20000000
  2.  
  3. #include <xc.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <math.h>
  7. #include <stdbool.h>
  8. #include <stdint.h>
  9. #include <string.h>
  10. #include "ESP8266_functions.h" //lch.h included in this library
  11.  
  12. // CONFIG
  13. #pragma config FOSC = HS // Oscillator Selection bits (INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
  14. #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
  15. #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
  16. #pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital input, MCLR internally tied to VDD)
  17. #pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)
  18. #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)
  19. #pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off)
  20. #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
  21.  
  22. char i;
  23.  
  24. void main()
  25. {
  26. GIE = 1; //ativando interrupções globais, para usar o USART
  27. PEIE = 1; //ativando as interrupções periféricas, para usar o USART
  28.  
  29. CMCON = 0x07;
  30.  
  31. TRISB = 0x00;
  32.  
  33. TRISA = 0b00001000; //Bbotão na RA3
  34.  
  35. Lcd_Init(); //Inicia LCD
  36.  
  37. Lcd_Clear();
  38.  
  39. PORTA=0;
  40.  
  41. PORTB=0;
  42.  
  43. Initialize_ESP8266(); //Inicializa ESP (configurações)
  44.  
  45. /*Check if the ESP_PIC communication is successful*/
  46. do
  47. {
  48. //Lcd_Set_Cursor(1,1);
  49. //Lcd_Write_String("ESP OFF");
  50. //PORTAbits.RA0=~PORTAbits.RA0;
  51. __delay_ms(1000);
  52.  
  53. }while (!esp8266_isStarted()); //wait till the ESP send back "OK"
  54.  
  55. Lcd_Set_Cursor(1,1);
  56. Lcd_Write_String("ESP ON");
  57.  
  58. inicia_esp8266();
  59.  
  60. while(1)
  61. {
  62. for (i=0;i<=10;i++) {
  63. PORTAbits.RA0=1;
  64. __delay_ms(50);
  65. PORTAbits.RA0=0;
  66. __delay_ms(50);
  67. }
  68.  
  69. envia_pagina();
  70.  
  71. recebe_pagina(); //recebe comando da pagina
  72.  
  73. }
  74. }
Add Comment
Please, Sign In to add comment