Quantcast
Viewing all articles
Browse latest Browse all 262198

MSP430G2553: Problem about MSP430 using with hc 06 bluetooth communication

Part Number:MSP430G2553

First of all,hello to all guys!

I have a problem about msp430 using with hc06 bluetooth communication, before that my main Project is gas detector , I used sample adc code and configured it according to gas sensor after that I add my Project to buzzer for alarm system with my sound function thats okey for now but I need to implement bluetooth hc06 for alerting android mobile phone for example 'Gas is detected' .I am in trouble with hc06 . I am working on led opening now but I could not response again. Android section is okey I guess, when click button1 it sends text '1' mathematical value and click button2 sends text '2' mathematical value. Please check my code and also if you guys have idea about my Project how can i write 'Gas is detected' in my adc please inform to me thanks in advance.

Here is my sample code for led opening via bluetooth  : 

#include "io430.h"
unsigned char Rx_Data = 0;  // Byte received via UART

int main(void)
{
 /*** Set-up system clocks ***/
  WDTCTL = WDTPW + WDTHOLD;  // Stop WDT
  if (CALBC1_1MHZ == 0xFF)  // If calibration constant erased
 {
 while (1); // do not load, trap CPU!
 }
 DCOCTL = 0;  // Select lowest DCOx and MODx settings
 BCSCTL1 = CALBC1_1MHZ; // Set DCO
 DCOCTL = CALDCO_1MHZ;

 /*** Set-up GPIO ***/
 P1SEL = BIT1 + BIT2;     // P1.1 = RXD, P1.2=TXD
 P1SEL2 = BIT1 + BIT2;     // P1.1 = RXD, P1.2=TXD
 P1DIR |= BIT6 + BIT0;     // P1.6 and P1.0 set as output
 P1OUT &= ~(BIT6 + BIT0);   // P1.6 and P1.0 set low
/*** Set-up USCI  ***/
 UCA0CTL1 |= UCSSEL_2;     // SMCLK
 UCA0BR0 = 104;       // 1MHz 9600
 UCA0BR1 = 0;       // 1MHz 9600
 UCA0MCTL = UCBRS0;      // Modulation UCBRSx = 1
 UCA0CTL1 &= ~UCSWRST;     // Initialize USCI state machine
          IE2 |= UCA0RXIE;      // Enable USCI_A0 RX interrupt
  __bis_SR_register(GIE);  // interrupts enabled
       
        if (Rx_Data== '1'){
   // P1SEL &= ~BIT6;     // P1.6 selected as GPIO
           P1OUT |= BIT6 + BIT0;   // P1.0 and P1.6 set high
        }
        if (Rx_Data == '0'){
 //  P1SEL &= ~BIT6;     // P1.6 selected as GPIO
   P1OUT &= ~(BIT6 + BIT0);  // P1.0 and P1.6 set low
        }
}
       
        //  USCI A interrupt handler
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB0RX_VECTOR))) USCI0RX_ISR (void)
#else
#error
#endif
;


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>