This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F479: UART data not correct

Part Number: MSP430F479

Hi,

I am trying to send one byte of data over the UART at a baud rate of 115200 Hz. I am using the BM70 ble module to transfer the data and the baud rate of the BM70 module is also 115200 Hz. I have connected the TX and RX pins of MSP430 of the RX and TX pins of BM70 module. I am just putting the byte I want to send in the Txbuffer of the MSP430 to see the data without using any interrupt. But when I send the data over the UART, it sends garbage data which I can see from the mobile app. Can you please tell me what I am doing wrong here?

Thanks

  • Can you please share your code? We can't do much without that.
  • Sure. The code is done in IAR environment which is attached below:


    #include <msp430.h>
    ;-------------------------------------------------------------------------------
    ; RSEG CSTACK ; Define stack segment
    ;-------------------------------------------------------------------------------
    ; RSEG CODE ; Assemble to Flash memory
    ORG 01100h ; Program Start
    ;-----------------------------------------------------------------------------
    RESET mov.w #0A00h,SP ; Initialize stackpointer
    StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT
    SetupFLL bis.b #XCAP11PF,&FLL_CTL0 ; Configure load caps

    OFIFGcheck bic.b #OFIFG,&IFG1 ; Clear OFIFG
    mov.w #047FFh,R15 ; Wait for OFIFG to set again if
    OFIFGwait dec.w R15 ;ORG 01100h ; Program Start not stable yet
    jnz OFIFGwait
    bit.b #OFIFG,&IFG1 ; Has it set again?
    jnz OFIFGcheck ; If so, wait some more

    SetupP1 bis.b #07h, &P1DIR
    bis.b #07h, &P1OUT

    SetupP2 bis.b #BIT4+BIT5,&P2SEL ; P2.4,5 USCI option select
    SetupUSCIA0 bis.b #UCSSEL_2,&UCA0CTL1 ; SMCLK
    mov.b #09,&UCA0BR0 ; 1MHz 115200
    mov.b #00,&UCA0BR1 ; 1MHz 115200
    mov.b #02,&UCA0MCTL ; Modulation
    bic.b #UCSWRST,&UCA0CTL1 ; **Initialize USCI state machine**
    bis.b #UCA0RXIE,&IE2 ; Enable USCI_A0 RX interrupt

    Main mov.b #85h,R6 ; data to be sent
    ; mov.w #56ACh, R7 ; data to be sent

    TZ1 bit.b #UCA0TXIFG,&IFG2 ; USCI_A0 TX buffer ready?
    jz TZ1 ; Jump if TX buffer not ready
    mov.b R6,&UCA0TXBUF
    ; swpb R7

    ;TZ2 bit.b #UCA0TXIFG,&IFG2 ; USCI_A0 TX buffer ready?
    ; jz TZ2 ; Jump if TX buffer not ready
    ; mov.b R7,&UCA0TXBUF
    ; swpb R7
    ;
    ;Mainloop bis.b #LPM3+GIE,SR ; Enter LPM3, interrupts enabled
    nop ; Needed only for debugger
    ;------------------------------------------------------------------------------
    USCIA0RX_ISR; Echo back RXed character, confirm TX buffer is ready first
    ;------------------------------------------------------------------------------
    TX0 bit.b #UCA0TXIFG,&IFG2 ; USCI_A0 TX buffer ready?
    jz TX0 ; Jump if TX buffer not ready
    mov.b &UCA0RXBUF,&UCA0TXBUF ; TX -> RXed character
    reti ;
    ;
    ;------------------------------------------------------------------------------
    ; COMMON INTVEC ; Interrupt Vectors
    ;------------------------------------------------------------------------------
    ORG 0FFF2h ; USCI_A0 Rx Vector
    DW USCIA0RX_ISR ;
    ORG 0FFFEh ; RESET Vector
    DW RESET ;
    END
  • Are you also connecting the BM70's GND with the MSP430 board GND?
    The minimum UART connection must have GND, TX, and RX.
  • Hello Sadique,

    First, we should make sure the hardware is working as expected.  

    What hardware you are using?  Is it a TI launchpad connected to the BLE module?   Please check that the boards share a GND connection as the community recommended. 

    It looks like the assembly code example your using came from the MSP430F79 example code pack: 

    As provided, The example should receive via the RX and echo out the TX.   Can you test the original example to confirm that your hardware is working as intended?  Is it possible to TX from the BLE module or another source and check the response?

    If that works, then we can narrow it down to a software issue.  

    Thanks,

    JD

     

  • Yes, I am connecting the BM70's GND with the MSP430 board GND and the BM70 module gets the proper voltage required to operate from the board.

  • No , I am not using the TI launchpad. I am using my own board with MSP430F479 in it. Yes, I have connected the common GND of the board to the BLE's common GND. Yes, I have checked the interrupt is working well. I have sent a number from the mobile app to the BLE module and the code is stopped in the break point where interrupt is used. Though it is not giving correct data in its RX-buffer.
  • Are you breakpointing at USCIA0RX_ISR?

      mov.b R6,&UCA0TXBUF
      nop ; Needed only for debugger
    USCIA0RX_ISR; Echo back RXed character, confirm TX buffer is ready first
    TX0 bit.b #UCA0TXIFG,&IFG2 ; USCI_A0 TX buffer ready?
      jz TX0 ; Jump if TX buffer not ready
      mov.b &UCA0RXBUF,&UCA0TXBUF ; TX -> RXed character
      reti ;
    

    As near as I can tell, you're falling through there immediately after sending the #85 byte. I suspect nothing has been received yet.

  • Hi, the code I attached there was what I tried to receive the data. The interrupt check was done using different code provided by the Texas instrument .
  • Hello,

    Md Sadique Hasan said:
    I am using my own board with MSP430F479 in it.

    Md Sadique Hasan said:
    Though it is not giving correct data in its RX-buffer.

    Thanks for confirming the hardware setup.  If you're not seeing the correct data being received with the provided example, then there is probably still a hardware related problem.  Possibly clocking frequency or baud rate is off for one of the devices.    

    Here are some things to check next:

    Please check your oscillator freq.  The example assumes a 32 kHz crystal.  

    Please confirm your SMCLK speed is what you expect.  You should be able to output it on P1.4 and measure it.  I believe it should be 1MHz based on the example software.

    Finally, please scope the UART lines with a logic analyzer/o-scope to confirm the BLE module is sending out the expected data at the correct baud rate. 

    Hopefully, this will have narrow down the issue. 

    Thanks!

    J.D.    

      

**Attention** This is a public forum