TODOPIC

Microcontroladores PIC => Todo en microcontroladores PIC => Mensaje iniciado por: MarkGP71 en 25 de Julio de 2017, 01:41:22

Título: porque no puedo comunicarme via bluetooth con mi pic16f1827
Publicado por: MarkGP71 en 25 de Julio de 2017, 01:41:22
hola tengo problemas a la hora de recibir datos, es una comunicacion con el celular donde apaga un led pero no hay respuesta, alguien puede ayudarme? gracias.

// CONFIG1
#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF        // Watchdog Timer Enable (WDT enabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = OFF       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
#pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = ON       // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON        // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)

// CONFIG2
#pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = OFF       // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = ON         // Low-Voltage Programming Enable (Low-voltage programming enabled)

#include <xc.h>


void interrupt recepcion ()
{
    char x;
    x = RCREG;
    if (x==49)
    {
        PORTA=0b00000001;
    }
    if (x==50)
    {
        PORTA=0b00000000;
    }
   
    PIR1bits.RCIF=0;
}

void main ()
{
    OSCCONbits.IRCF=1100;      // 2 Mhz cristal interno
    OSCCONbits.SCS=10;         // Fuente del reloj
   
    TRISA = 0;
    PORTA = 0;
   
   
    TRISB = 0b00000010;
    PORTB = 0;
   
    INTCONbits.GIE=1;
    INTCONbits.PEIE=1;
   
    PIE1bits.RCIE=1;
   
    PIR1bits.RCIF=0;
   
    RCSTAbits.SPEN=1;
    RCSTAbits.CREN=1;
   
    TXSTAbits.SYNC=0;
   
    BAUDCONbits.BRG16=0;
    TXSTAbits.BRGH=0;
   
    SPBRG = 51;

   
    while (1)
    {
       
    }
}
Título: Re:porque no puedo comunicarme via bluetooth con mi pic16f1827
Publicado por: KILLERJC en 25 de Julio de 2017, 08:57:12
¿estas enviando lo correcto?.

Vos estas esperando que llegue un '1' o un '2'

Y una cosa mas, primero se configura el modulo ,luego se activa sus interrupcion y finalmente el modulo, hiciste todo a la inversa
Título: Re:porque no puedo comunicarme via bluetooth con mi pic16f1827
Publicado por: xocas en 29 de Julio de 2017, 06:37:20
Por favor MarkGP71, lee las Reglas del Foro (http://www.todopic.com.ar/foros/index.php?action=announcements;aid=1). He borrado dos temas tuyos con esta misma consulta.

Gracias