UART for MSP430FR5969

I am new to using MSP430FR5969 .

I want to program my uart1 to bluetooth PAN1026 using MSP430 .

at the beginning i send rest mode { 0x01, 0x03,0x0c,0x00 }

and bluetooth should answer me
{ 0x04,0x0e,0x04,0x04,0x03,0x0c,0x00 }

So, I want to condition on UCA1RXBUF

, it should be equal { 0x04,0x0e,0x04,0x04,0x03,0x0c,0x00 }

until I go to the second step

else I'll redo the first step.

Here is my code.

    #include "usart.h"
    void USART0_Init (void) {   // Controller -> PC
    P2SEL1 |= BIT0| BIT1;                    // Configure UART pins
      P2SEL0 &= ~(BIT0| BIT1);

      // Disable the GPIO power-on default high-impedance mode to activate
      // previously configured port settings
      PM5CTL0 &= ~LOCKLPM5;

      // Startup clock system with max DCO setting ~8MHz
      CSCTL0_H = CSKEY >> 8;                    // Unlock clock registers
      CSCTL1 = DCOFSEL_3 | DCORSEL;             // Set DCO to 8MHz
      CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
      CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1;     // Set all dividers
      CSCTL0_H = 0  ;                           // Lock CS registers

      // Configure USCI_A1 for UART mode
      UCA0CTLW0 = UCSWRST;                      // Put eUSCI in reset
      UCA0CTLW0 |= UCSSEL__SMCLK;               // CLK = SMCLK
      UCA0BR0 = 4;     //4;                             // 8000000/16/115200
      UCA0BR1 = 0x00;
      UCA0MCTLW |= 0x55;                         //UCOS16 | UCBRF_1;
      UCA0CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
     // UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

}
void USART1_Init (void) {   // Controller <-> PAN1026

    P2SEL1 |= BIT5| BIT6;                    // Configure UART pins
      P2SEL0 &= ~(BIT5| BIT6);

      // Configure USCI_A1 for UART mode
      UCA1CTLW0 = UCSWRST;                      // Put eUSCI in reset
      UCA1CTLW0 |= UCSSEL__SMCLK;               // CLK = SMCLK
      UCA1BR0 = 4;                             // 8000000/16/115200
      UCA1BR1 = 0x00;
      UCA1MCTLW |=0x55; //UCOS16 | UCBRF_1;
      UCA1CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
     // UCA1IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
}
void USART0_SendByte (unsigned char data) {
    while(!(UCA0IFG & UCTXIFG));
    UCA0TXBUF = data;
}
void USART1_SendByte (unsigned char data) {
    while(!(UCA1IFG & UCTXIFG));
    UCA1TXBUF = data;
}
void USART0_SendData (unsigned char data[], unsigned char length) {
    unsigned char i;

    for(i=0; i<length; i++) {
        USART0_SendByte(data[i]);
    }
}
void USART1_SendData (unsigned char data[], unsigned char length) {

    unsigned char i;

    for(i=0; i<length; i++) {
        USART1_SendByte(data[i]);
    }
}
----------------------------------------------------------------------------------------------------------------------
#include <msp430.h>
// Header files
#include "usart.h"

unsigned char TCU_HCI_RESET_REQ[4] = {0x01, 0x03, 0x0c, 0x00};

void main(void) {

        WDT_A_hold(WDT_A_BASE);

    USART0_Init();
    USART1_Init();
while(1){
    USART0_SendData(TCU_HCI_RESET_REQ,4);
    USART1_SendData(TCU_HCI_RESET_REQ,4);
    __delay_cycles(150000);
}
}

      

+3


source to share


1 answer


you need to write a UART

receive procedure ISR

and store the data coming from PAN1026

. Then after exiting, ISR

you can check the data with Bluetooth and make the appropriate decision.



+1


source







All Articles