Advertisement
Mukmin039

Main_NRFL_2

Oct 18th, 2023
1,045
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 19.98 KB | Software | 0 0
  1. /*
  2.  * File:   MatchingWristMain.c
  3.  * Author: Rito III
  4.  *
  5.  * Created on 7 de abril de 2022, 7:08
  6.  */
  7.  
  8.  
  9. #include "xc.h"
  10. #include "stdio.h"
  11. #include "math.h"
  12. //#include "iostream.h"
  13. //#include "FastLED.h"
  14. #include "../nrf24_lib.h"
  15. #include "build/default/debug/../production/mcc_generated_files/../../production/mcc_generated_files/../../../../string.h"
  16. #include "../mcc_generated_files/mcc.h"
  17. #include"string.h"
  18.  
  19.  
  20.  
  21. NRF24_INIT_STATUS ret;
  22. unsigned char i;
  23. unsigned char bufferTX[50];
  24. unsigned char bufferRX[50];
  25. //int NRF24L01_TX_EX = 1;
  26. //int NRF24L01_RX_EX = 0;
  27. #define NRF24L01_TX_EX  1
  28. #define NRF24L01_RX_EX  !NRF24L01_TX_EX
  29.  
  30. char datos={0};//number of the device plus personal data
  31. char buffer;
  32.  
  33.  
  34.  
  35. char dispositivo[3];
  36. char genero[3];
  37. int age;
  38. char edo_civil[3];
  39. char hijos[3];
  40. char religion [3];
  41. char educacion[3];
  42. char toma[3];
  43. char fuma[3];
  44. char ocupacion[3];
  45. char caracter[3];
  46. char casa[3];
  47. char carro[3];
  48. char comportamiento[3];
  49.  
  50. char dispositivo_h[3];
  51. char genero_h[3];
  52. int age_h;
  53. char edo_civil_h[3];
  54. char hijos_h[3];
  55. char religion_h [3];
  56. char educacion_h[3];
  57. char toma_h[3];
  58. char fuma_h[3];
  59. char ocupacion_h[3];
  60. char caracter_h[3];
  61. char casa_h[3];
  62. char carro_h[3];
  63. char comportamiento_h[3];
  64.  
  65. //const unsigned long long pipes[2] = { 0xEEFDFDFDECLL, 0xEEFDFDF0DFLL };
  66.  
  67.  
  68.  
  69.  
  70. void blink_led() {
  71.     LED_Toggle();
  72. }
  73.  
  74.  
  75.        
  76.  
  77.  
  78.  
  79. //#define LED_PIN 2
  80. //#define NUM_LED 3
  81.  
  82. //CRGB leds[NUM_LED];
  83.  
  84. //void setup ()
  85. //{
  86. //FastLED.addLeds<WS2812,LED_PIN, RGB>(leds,NUM_LED);
  87. //FastLED.SetMaxPowerInVoltsAndMilliamps(3,300);
  88. //leds[1]= CRGB (0,255,0);
  89. //FastLED.show();
  90. //FastLED.clear();
  91. //}
  92.  
  93.  
  94.  
  95.  
  96. void Led_color(int color)
  97. {
  98. if (color==1)
  99. {
  100. //leds[1]= CRGB[255,0,0];
  101. //FastLED.show();
  102. int k;
  103. for (k=0;k<= 6;k++)
  104. {
  105.     LATBbits.LATB5 = 1;
  106.     LATBbits.LATB4 = 1;
  107.     LATBbits.LATB3 = 1;
  108.  
  109. __delay_ms(1000);
  110. LATBbits.LATB3 = 0;
  111. LATBbits.LATB4 = 0;
  112. LATBbits.LATB5 = 0;
  113.  __delay_ms(1000);
  114.    
  115. //printf("blink Red color\n");
  116. }
  117. }
  118. if (color==2)
  119. {
  120. //leds[1]= CRGB[0,0,255];
  121. //FastLED.show();
  122. int w;
  123. for (w=0;w<= 6;w++)
  124. {
  125.  
  126.  
  127.  LATBbits.LATB0 = 1;
  128.  LATBbits.LATB1= 1;
  129.  LATBbits.LATB2 = 1;
  130.  
  131. __delay_ms(1000);
  132.  LATBbits.LATB0 = 0;
  133.  LATBbits.LATB1= 0;
  134.  LATBbits.LATB2 = 0;
  135. __delay_ms(1000);
  136. //printf("blink yellow color\n");
  137. }
  138. }
  139. if (color==3)
  140. {
  141. int z;
  142. for (z=0;z<= 6;z++)
  143. {
  144.  
  145. LATDbits.LATD5 = 1;
  146. LATDbits.LATD6 = 1;
  147. LATDbits.LATD7 = 1;
  148. __delay_ms(1000);
  149. LATDbits.LATD5 = 0;
  150. LATDbits.LATD6 = 0;
  151. LATDbits.LATD7 = 0;
  152. __delay_ms(1000);
  153. //printf("blink green colour\n");
  154. }
  155. }
  156. }
  157. //void timer1_interrupt (void)
  158. //{
  159.    
  160.    
  161. //}
  162.  
  163. /*
  164. void timer1_run (void)
  165. {
  166.     //initialize the timer
  167.     TMR1=0; //TIMER 1 CON OSCILADOR EXTERNO Y PRESCALER DE 8
  168.     T1CONbits.TMR1ON = 0;//apago el timer 1 y es tambien para la interrupcion del rollover
  169.     T1CONbits.TMR1CS = 0b10;//lo configuro con oscilador externo
  170.     T1CONbits.T1CKPS = 0b11;//lo configuro con 1 de preescaler
  171.     T1CONbits.SOSCEN = 1;//configuro para oscilador externo
  172.     OSCCON2bits.SOSCGO = 1; //configuro para oscilador externo con entrada en SOSCO/SOSCI pins
  173.     PIE1bits.TMR1IE = 1;//habilita interrupcion
  174.     //inicializamos contadores y TMR1 registros
  175.     TMR1H = 0;
  176.     TMR1L = 0;
  177.     PIR1bits.TMR1IF = 0; //para borrar la interrupcion por desbordamiento del timer
  178.     T1CONbits.T1SYNC = 1; //para syncronizar el oscilador  
  179.    
  180.     TMR1=0xFB1E; // 64,286 para contar 200 msec por 100 veces
  181.     T1CONbits.TMR1ON = 1;//enciendo el timer
  182.    
  183. }*/
  184.  
  185.  
  186. void seleccion (unsigned char* t, unsigned char* r){
  187.  
  188. unsigned char host[50];
  189. unsigned char data[50];
  190.  
  191. char soltero[3] = {"67"};
  192. char casado [3]= {"68"};
  193. char divorciado[3] = {"69"};
  194. char complicado[3] = {"6A"};
  195. char con_hijos[3]= {"6B"};
  196. char sin_hijos[3] ={"6C"};
  197. char catolico[3]={"6D"};
  198. char cristiano[3]={"6E"};
  199. char musulman[3] = {"6F"};
  200. char ateo[3] = {"70"};
  201. char testigo[3] = {"71"};
  202. char luz_mundo[3] = {"72"};
  203. char sin_religion[3] = {"73"};
  204. char otra[3] = {"74"};
  205. char ingeniero[3] = {"75"};
  206. char no_importa[3] = {"9B"};
  207. char licenciado[3] = {"76"};
  208. char master [3]= {"77"};
  209. char doctorado[3] = {"78"};
  210. char tecnico[3] = {"79"};
  211. char prepa[3] = {"7A"};
  212. char secundaria [3]= {"7B"};
  213. char primaria[3] = {"7C"};
  214. char sin_estudios[3] = {"7D"};
  215. char drinks[3] = {"7E"};
  216. char no_toma[3] ={"7F"};
  217. char smoke[3] = {"80"};
  218. char no_fuma[3] = {"81"};
  219. char empleado[3] = {"82"};
  220. char comerciante[3] = {"83"};
  221. char business_owner[3] = {"84"};
  222. char sin_trabajo[3] = {"85"};
  223. char ama_de_casa[3] = {"86"};
  224. char caracter_fuerte[3] = {"87"};
  225. char caracter_dulce [3]= {"88"};
  226. char timido [3]= {"89"};
  227. char bondadoso[3] = {"8A"};
  228. char agarrado[3] = {"8B"};
  229. char honesto [3]= {"8C"};
  230. char trakala [3]= {"8D"};
  231. char casa_propia[3] = {"8E"};
  232. char renta [3]= {"8F"};
  233. char carro_propio[3] = {"90"};
  234. char sin_carro [3]= {"91"};
  235. char buen_corazon[3] = {"92"};
  236. char romantico [3]= {"93"};
  237. char detallista [3]= {"94"};
  238. char con_mala_memoria [3]= {"95"};
  239. char no_romantico[3] = {"96"};
  240. char no_detallsita [3]= {"97"};
  241. char colerico[3] = {"98"};
  242. char protector[3] = {"99"};
  243. char abusivo [3]= {"9A"};
  244.  
  245.  
  246.  
  247. strcpy (data,t);
  248. strcpy(host,r);
  249.  
  250. char d[]=",";
  251.  
  252.  char *datap0 = strtok(data,d);
  253. strcpy(dispositivo ,datap0); // add the device
  254.  char *datap1=strtok(NULL,d);
  255. strcpy(genero ,datap1); // add the gender
  256.  char *datap2=strtok(NULL,d);
  257. age= atoi(datap2);  //add the age and converted into integer
  258.  char *datap3=strtok(NULL,d);
  259. strcpy(edo_civil,datap3);//if married or not
  260.  char *datap4=strtok(NULL,d);
  261. strcpy(hijos,datap4);//if any kids
  262.  char *datap5=strtok(NULL,d);
  263. strcpy(religion,datap5); // religion
  264.  char *datap6=strtok(NULL,d);
  265. strcpy(educacion ,datap6);//education
  266.  char *datap7=strtok(NULL,d);
  267. strcpy(ocupacion,datap7);//drinks
  268.  char *datap8=strtok(NULL,d);
  269. strcpy(caracter ,datap8);//smokes
  270.  char *datap9=strtok(NULL,d);
  271. strcpy(toma ,datap9); //occupation
  272.  char *datap10=strtok(NULL,d);
  273. strcpy(fuma ,datap10);//character
  274.  char *datap11=strtok(NULL,d);
  275. strcpy(casa ,datap11);//house
  276. char *datap12=strtok(NULL,d);
  277. strcpy(carro ,datap12);//car
  278.  char *datap13=strtok(NULL,d);
  279. strcpy(comportamiento,datap13);//comportamiento
  280.  char *datap14=strtok(NULL,d);
  281.  
  282. //host
  283.  char *hostp0 = strtok(host,d);
  284. strcpy(dispositivo_h,hostp0);//add the device into the string
  285.  char *hostp1=strtok(NULL,d);
  286. strcpy(genero_h,hostp1); // add the gender
  287.  char *hostp2=strtok(NULL,d);
  288. age_h= atoi(hostp2);  //add the age and converted into integer
  289.  char *hostp3=strtok(NULL,d);
  290. strcpy(edo_civil_h,hostp3);//if married or not
  291.  char *hostp4=strtok(NULL,d);
  292.  strcpy(hijos_h,hostp4);//if any kids
  293.  char *hostp5=strtok(NULL,d);
  294. strcpy(religion_h ,hostp5);//religion
  295.  char *hostp6=strtok(NULL,d);
  296. strcpy(educacion_h ,hostp6);//education
  297. char *hostp7=strtok(NULL,d);
  298. strcpy(ocupacion_h ,hostp7);//drinks
  299.  char *hostp8=strtok(NULL,d);
  300. strcpy(caracter_h ,hostp8);//smokes
  301.  char *hostp9=strtok(NULL,d);
  302. strcpy(toma_h ,hostp9); //occupation
  303.  char *hostp10=strtok(NULL,d);
  304. strcpy(fuma_h ,hostp10);//character
  305.  char *hostp11=strtok(NULL,d);
  306. strcpy(casa_h ,hostp11);//house
  307.  char *hostp12=strtok(NULL,d);
  308. strcpy(carro_h ,hostp12);//car
  309. char *hostp13=strtok(NULL,d);
  310. strcpy(comportamiento_h,hostp13);//comportamiento
  311. char *hostp14=strtok(NULL,d);
  312.  
  313.  
  314.   if ( strcmp(genero,genero_h)!=0 )//revisa genero
  315.     {
  316.         if ( age_h <= age  )//revisa edad
  317.         {
  318.         //printf("Edad compatible\n");//tengo que diseñar algo que me actualize esto sin conectarme a la pulsera
  319.             if (( strcmp(edo_civil_h,soltero)==0 )||(strcmp(edo_civil_h,divorciado)==0 )||(strcmp(edo_civil_h,complicado)==0 ))//revisa estado civil
  320.             {
  321.             //printf("Estado civil compatible\n");
  322.                 if (strcmp(hijos_h,sin_hijos)==0)//sin hijos
  323.                 {
  324.                 //printf("Hijos compatible\n");
  325.                     if (strcmp(religion,religion_h)==0)//misma.religion
  326.                     {
  327.                     //printf("Religion compatible\n");
  328.                         if ((strcmp(educacion_h,ingeniero)==0)||(strcmp(educacion_h,licenciado)==0)||(strcmp(educacion_h,master)==0)||(strcmp(educacion_h,doctorado)==0)||(strcmp(educacion_h,no_importa)==0))
  329.                         {
  330.                         //printf("educacion compatible\n");
  331.                             if ((strcmp(ocupacion_h,empleado)==0)||(strcmp(ocupacion_h,comerciante)==0)||(strcmp(ocupacion_h,business_owner)==0)||(strcmp(ocupacion_h,ama_de_casa)==0)) // le gusta la profesion
  332.                             {
  333.                             //printf("ocupacion compatible\n");  
  334.                                 if ((strcmp(caracter_h,caracter_dulce)==0)||(strcmp(caracter,timido)==0)||(strcmp(caracter_h,bondadoso)==0)||(strcmp(caracter_h,trakala)==0))
  335.                                 {
  336.                                 //printf("caracter_compatible\n");
  337.                                     if (strcmp(toma_h,no_toma)==0)//si no toma
  338.                                     {
  339.                                     //printf("Bebida compatible\n");
  340.                                         if (strcmp(fuma_h,no_fuma)==0)//si no fuma
  341.                                         {
  342.                                         //printf("Fumar compatible\n");
  343.                                             if (strcmp(casa_h,casa_propia)==0 )//likes have a house
  344.                                             {
  345.                                             //printf("Casa compatible\n");
  346.                                                 if (strcmp(carro_h,carro_propio)==0)//likes have a car
  347.                                                 {
  348.                                                 //printf("Carro compatible\n");
  349.                                                     if ((strcmp(comportamiento_h,buen_corazon)==0 )||(strcmp(comportamiento_h,romantico)==0)||(strcmp(comportamiento_h,detallista)==0)||(strcmp(comportamiento_h,protector)==0))//likes behaviour
  350.                                                     {
  351.                                                       // printf("Personalidad compatible\n");
  352.                                                      Led_color(3);
  353.                                                     }
  354.                                                     else
  355.                                                     {
  356.                                                     //flash yellow wrist
  357.                                                     //printf("personalidad no compatible\n");
  358.                                                     Led_color(2);
  359.                                                     }
  360.                                                 }    
  361.                                                 else
  362.                                                 {
  363.                                                 //printf("carro no compatible\n");Led_color(2);
  364.                                                 //flash yellow.wrist
  365.                                                         Led_color(2);
  366.                                                 }
  367.                                             }  
  368.                                             else
  369.                                             {
  370.                                             //printf("casa no compatible\n");Led_color(2);                
  371.                                             //flash yellow wrist
  372.                                                     Led_color(2);
  373.                                             }        
  374.                                         }
  375.                                         else
  376.                                         {
  377.                                         //printf("Fumar no compatible\n");
  378.                                         Led_color(2);
  379.                                         //flash.red wrist
  380.                                         }
  381.                                     }
  382.                                     else
  383.                                     {
  384.                                     //printf("Bebida no compatible\n");
  385.                                     Led_color(2);
  386.                                     //flash red wrist
  387.                                     }
  388.                                 }
  389.                                 else
  390.                                 {
  391.                                  //printf("caracter no compatible\n");
  392.                                  Led_color (1);
  393.                                  //flash red color  
  394.                                 }
  395.                             }    
  396.                             else
  397.                             {
  398.                             //printf("Ocupacion no compatible\n");Led_color(2);
  399.                             //flash yellow.wrist
  400.                              Led_color(1);  
  401.                             }
  402.                         }
  403.                         else
  404.                         {
  405.                         //printf("estudios no compatible\n");
  406.                         Led_color(1);
  407.                         //flash red wrist
  408.                         }    
  409.                     }
  410.                     else
  411.                     {
  412.                     //printf("Religion no compatible\n");
  413.                     Led_color(1);
  414.                     ///flash red wrist
  415.                     }        
  416.                 }
  417.                 else
  418.                 {
  419.                 //printf("hijos no compatible\n");
  420.                 Led_color(1);
  421.                 //flash red wrist
  422.                 }
  423.             }
  424.             else
  425.             {
  426.             //printf("Estado civil no compatible\n");
  427.             Led_color(1);
  428.             //flash red wrist
  429.             }    
  430.         }
  431.         else
  432.         {
  433.         //printf("Edad no compatible\n");
  434.         Led_color(1);
  435.         //flash red wrist
  436.         }        
  437.     }
  438.     else
  439.     {
  440.     //finito:
  441.     Led_color(1);
  442.         //printf("Genero no compatible\n");
  443.     //led_color(1);    
  444.     }
  445. }
  446.  
  447.  
  448. void main()
  449. {
  450.  
  451.     // Initialize the device
  452.     SYSTEM_Initialize();
  453.  
  454.     // If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
  455.     // If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts
  456.     // Use the following macros to:
  457.  
  458.     // Enable the Global Interrupts
  459.     INTERRUPT_GlobalInterruptEnable();
  460.  
  461.     // Disable the Global Interrupts
  462.     //INTERRUPT_GlobalInterruptDisable();
  463.  
  464.     // Enable the Peripheral Interrupts
  465.     INTERRUPT_PeripheralInterruptEnable();
  466.  
  467.     // Disable the Peripheral Interrupts
  468.     //INTERRUPT_PeripheralInterruptDisable();  
  469. //TMR0_Initialize();    
  470. TMR0_SetInterruptHandler(blink_led);
  471. //TMR0_StartTimer();    
  472. SPI1_Open(SPI1_DEFAULT);  
  473. TRISB = 0;
  474. TRISD =0;
  475.  
  476.  
  477.  
  478.  
  479. #if NRF24L01_TX_EX
  480.    ret = nrf24_rf_init(TX_MODE, 0b00000010); // Tx mode with 2400+115 Ghz RF frq
  481. #elif NRF24L01_RX_EX
  482.     ret = nrf24_rf_init(RX_MODE, 115); // Rx mode with 2400+115 Ghz RF frq
  483. #endif
  484.     //enableAckPayload();
  485.    
  486.  if (ret == NRF24_INIT_OK)
  487.     {
  488.         printf("###############################################################\r\n");
  489.         printf("NRF24L01 Initialize successful\r\n");
  490.         nrf24_printf_rf_config();
  491.         printf("###############################################################\r\n");
  492. }
  493.  else
  494.      {
  495.         printf("###############################################################\r\n");
  496.         printf("Failed Initialize NRF24L01\r\n");
  497.         printf("###############################################################\r\n");
  498.         }
  499.        
  500. //#if NRF24L01_TX_EX
  501.  
  502.  //char memoria [5][50];
  503.  
  504.     while (1)
  505.     {      
  506.  
  507.  //while (txcounter <= 2)//cuantas veces quiero que transmita
  508. //{  
  509.   //  txcounter++;    
  510. #if NRF24L01_TX_EX
  511.        
  512.         sprintf((char*)bufferTX,"01,00,03,04,05,06,07,08");//ejemplo verde
  513.    
  514.          nrf24_send_rf_data(bufferTX);
  515.     LATBbits.LATB0 = 1;
  516.     __delay_ms(100);
  517.    LATBbits.LATB0 = 0;
  518.    __delay_ms(100);
  519.    //sprintf((char*)bufferRX,"01,66,42,67,6C,6F,82,88,7F,81,8E,90,92");//ejemplo rojo
  520.     sprintf((char*)bufferTX,"01,00,03,04,05,06,07,08");
  521.    nrf24_send_rf_data(bufferTX);
  522.    __delay_ms(100);
  523.          LATBbits.LATB0 = 1;
  524.     __delay_ms(100);
  525.    LATBbits.LATB0 = 0;
  526.    __delay_ms(100);
  527.  
  528.    //sprintf((char*)bufferRX,"01,66,20,69,6C,6F,9B,82,88,7F,81,8F,90,92");//ejemplo amarillo
  529.     sprintf((char*)bufferTX,"01,00,03,04,05,06,07,08");
  530.          nrf24_send_rf_data(bufferTX);
  531.     LATBbits.LATB0 = 1;
  532.     __delay_ms(100);
  533.    LATBbits.LATB0 = 0;
  534.    __delay_ms(100);
  535.     //nrf24_read_rf_data(bufferRX);//activar
  536.    // sprintf((char*)bufferRX,"01,66,42,67,6C,6F,82,88,7F,81,8E,90,92");//ejemplo rojo
  537.     //sprintf((char*)bufferRX,"01,66,20,69,6C,6F,9B,82,88,7F,81,8E,90,92");//ejemplo verde
  538.     //sprintf((char*)bufferRX,"01,66,20,69,6C,6F,9B,82,88,7F,81,8F,90,92");//ejemplo amarillo
  539.    // TRISBbits.RB0 = 1;
  540.   //  __delay_ms(100);//activar
  541.    // TRISBbits.RB0 = 0;
  542.  
  543. //}
  544. //lo muevo a modo receptor
  545. //seleccion(bufferTX, bufferRX);
  546.  
  547. #elif NRF24L01_RX_EX
  548.  
  549.  
  550.  
  551.     //nrf24l01_read_rf_data(bufferrx)
  552.     //printf("please input your host data");
  553.     //scanf("%c",&buffer);
  554.    
  555.     //sprintf(host[x],"datos%x",bufferrx);
  556.     //puts(homemst);
  557.    
  558.  //}
  559.  
  560.  
  561.  
  562.  
  563.  /*if (z<=5)
  564.  {
  565.      z++;
  566.      strcpy(memoria[z],bufferRX);
  567.      
  568.  }  
  569. */
  570.  
  571.  
  572.  
  573. //give values to the constants
  574.  
  575.    
  576. //data reception
  577. //#elif nr24l01_rx_ex
  578. //while nr24l01_data available
  579.  
  580. /*printf("dispositivos a comparar=%x,%x\n",data[0],host[0]);
  581. int c=2;
  582. while (c<=5)
  583. {
  584.     if (strcmp(memoria[c], bufferRX)== 0)
  585.     {//printf("dispositivo ya escaneado");
  586.     goto finito;    
  587.     }
  588.     else
  589.     {c++;
  590.        
  591.     }    
  592. }
  593. */
  594.  
  595.    
  596. //NRF24L01_TX_EX =0;
  597. //NRF24L01_RX_EX =1;
  598.  
  599.     ret = nrf24_rf_init(RX_MODE, 115); // Rx mode with 2400+115 Ghz RF frq
  600.     //TRISBbits.RB0 = 1;
  601.     __delay_ms(100);
  602.     //TRISBbits.RB0 = 0;
  603.     //__delay_ms(100);        //actvar
  604.    nrf24_read_rf_data(bufferRX);//este es el bueno
  605.    //TRISBbits.RB0 = 1;
  606.     __delay_ms(100); //activvar
  607.     //TRISBbits.RB0 = 0;
  608.     writeAckPayload (0,bufferTX,32);//activar
  609. //TRISBbits.RB0 = 1;
  610.     //__delay_ms(100);
  611.   //  TRISBbits.RB0 = 0;
  612.    
  613.    // seleccion (bufferTX, bufferRX);activar
  614.  
  615.  
  616. /*  
  617.  //initialize the timer
  618.     TMR1=0; //TIMER 1 CON OSCILADOR EXTERNO Y PRESCALER DE 8
  619.     T1CONbits.TMR1ON = 0;//apago el timer 1 y es tambien para la interrupcion del rollover
  620.     T1CONbits.TMR1CS = 0b01;//lo configuro con oscilador interno
  621.     T1CONbits.T1CKPS = 0b11;//lo configuro con 1 de preescaler
  622.     T1CONbits.SOSCEN = 0;//configuro para oscilador interno
  623.    // OSCCON2bits.SOSCGO = 0; //configuro para oscilador externo con entrada en SOSCO/SOSCI pins
  624.     OSCCON =0b00110110;// se configura el reloj a interno con una frecuencia de 1 Mhz
  625.     PIE1bits.TMR1IE = 0;//deshabilita interrupcion
  626.     //inicializamos contadores y TMR1 registros
  627.     TMR1H = 0;
  628.     TMR1L = 0;
  629.     PIR1bits.TMR1IF = 0; //para borrar la interrupcion por desbordamiento del timer
  630.    // T1CONbits.T1SYNC = ; //para syncronizar el oscilador  
  631.    
  632.     TMR1=0x3CB0; // 15,536 para contar 200 msec
  633.     T1CONbits.TMR1ON = 1;//enciendo el timer
  634.  //data reception
  635.    
  636.     //bufferRX[32]= "016642676C6F9B7F8182889B9B92";
  637.     //
  638.     while (PIR1bits.TMR1IF==0) //otra vez hago el ciclo para que empieze a contar
  639.      
  640.     {
  641.        
  642.     nrf24_read_rf_data(bufferRX);
  643.     //printf("NRF24 Receive Data: %s\r\n", bufferRX);
  644.     __delay_ms(10);*/
  645.    
  646.   /*              
  647.                    
  648. //char guest2[50];
  649. //for (int y=0;y<=13;y++)
  650. //{
  651. //sprintf(guest2, "host %x", host[y]);
  652. //puts(guest2);
  653. //}
  654. //PIR1bits.TMR1IF = 0;//apago la bandera de desboradmiento del timer
  655. // T1CONbits.TMR1ON = 0;//apago el timer
  656. // PIR1bits.TMR1IF = 0;//apago la bandera de desboradmiento del timer
  657. // TMR1H = 0;//iniciallizo los timer TMR1h y L
  658. // TMR1L = 0;
  659. // TMR1=0x3CB0; // 15,536 para contar 200 msec  
  660. // T1CONbits.TMR1ON = 1;//enciendo el timer
  661. //compatibility
  662.  
  663.                    
  664.                  
  665.                
  666. */              
  667. #endif
  668.    
  669.              
  670. }            
  671. }
  672.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement