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.

MSP430G2553 can not receive the byte follows the address byte in Idle Line Multiprocess format in UART mode

Other Parts Discussed in Thread: MSP430G2553

I found for MSP430G2553, in UART mode with Idle Line Multiprocessor mode, the byte follows the address can not trigger the interrupt, the byte lost, below is the tool I used on PC to send the RS232 data, the string I attempt to send is 0x0A, 0x01, the first 0A can be received as address, but second byte 0x01 can not trigger interrupt, the target I am using is the launchpad with G2553 in place.

Below is the initialise code:

void UARTInitialise()

{

       P1SEL |= BIT1 + BIT2;

       P1SEL2 |= BIT1 + BIT2;

       ADC10AE0 &= 0xF9;

       CAPD &= 0xF9;        //set P1.1 to RXD, P1.2 to TXD

 

       UCA0CTL1 |= 1;

       UCA0CTL0 = 0x82;   //Select idle-line mode, Parity enable, odd, 8-bit data, one stop bit, asynchronous mode

       UCA0CTL1 = 0xB9;     //SMClock, UCRXEIE = 1, UCBRKEIE = 1; UCDORM = 1; UCTXADDR = 0, UCTXBRK = 0, UCSWRST = 1;

 

       UCA0BR0 = 104;

       UCA0BR1 = 0;

       UCA0MCTL = 0x31;   //UCOS16 = 1; Baud Rate = 9600

 

       UCA0STAT |= 0x0;

 

//     IE2 |= UCA0RXIE;                  //UCA0TXIE, UCA0RXIE = 01

//     IE2 |= UCA0TXIE;

}

 I am attaching the .c and .h for further investigationbqMaximo_Ctrl_G2553.h

6763.main.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <msp430.h>
#include <stdbool.h>
#include <bqMaximo_Ctrl_G2553.h>
#include <math.h>
#include <float.h>
#include <stdlib.h>
/*
* main.c
*/
RegisterGroup Registers;
const unsigned int OVPThreshold = 4300;
const unsigned int UVPThreshold = 2500;
const unsigned char SCDDelay = SCD_DELAY_100us;
const unsigned char SCDThresh = SCD_THRESH_89mV_44mV;
const unsigned char OCDDelay = OCD_DELAY_320ms;
const unsigned char OCDThresh = OCD_THRESH_22mV_11mV;
const unsigned char OVDelay = OV_DELAY_2s;
const unsigned char UVDelay = UV_DELAY_8s;
unsigned int CellVoltage[15];
float Gain = 0;
int iGain = 0;
void ClockInitialise()
{
DCOCTL = 0xE0; //DCO = 7, MOD = 0
BCSCTL1 &= 0x8F; //RSEL = 0, DCOR = 0, 20MHz Clock
BCSCTL2 = 0x0;
BCSCTL3 = 0;
}
void TimerAInit()
{
TA0CTL |= TASSEL1;
TA0CTL &= ~TASSEL0;
TA0CTL |= MC1;
TA0CTL &= ~MC0;
TA0CTL &= ~TAIE;
}
void I2CInitialise()
{
P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0, P1.6 for SCL and P1.7 for SDA
P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0, P1.6 for SCL and P1.7 for SDA
ADC10AE0 &= 0x3F;
CAPD &= 0x3F;
UCB0CTL1 |= UCSWRST; // Enable SW reset, hold USCI logic in reset state
UCB0CTL0 = UCMODE_3 + UCSYNC; //set to I2C mode, sync=1
UCB0BR0 = 20;
UCB0BR1 = 0;
UCB0I2CIE = 0;
IE2 &= ~(UCB0TXIE + UCB0RXIE); //disable interrupts
UCB0CTL1 |= UCSSEL_2;
UCB0CTL1 &= ~UCSWRST;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Steven,

    Using the header file definitions for the register settings is easier to read for others. For example:

    //Select idle-line mode, Parity enable, odd, 8-bit data, one stop bit, asynchronous mode
    UCA0CTL0 = UCPEN | UCMODE_1; // Instead of writing 0x82

    From this line

    UCA0MCTL = 0x31; // UCOS16 = 1; Baud Rate = 9600

    I guess your clock frequency is 16MHz? Always add those information, especially when wrong baudrate settings can be a source for errors.

    Sorry, this is no solution for problem, just a hint.


    Dennis

  • Dennis

    Thanks for your comments, the style you suggest is a good practice for coding.
    Yes, as you said, I set the frequency to 16MHz, and set UCBR0, UCBR1, UCA0MCTL to configure the baud rate to 9600. I found I can send data to PC correctly, but the MCU can not receive the data from PC correctly, is there a minimum interval request between the address and following data?
  • Where do you release your USCI from reset again?
  • Dennis

        It is released in the function below:

    void EnableUART()
    {
     UCA0CTL1 &= ~UCSWRST;
     IE2 |= UCA0RXIE;   //Enable Receive interruption
     IE2 &= ~UCA0TXIE;   //Disable Transmit interruption
    }

        This function is called before while(1) circulation, I sent the 0x0a, 0x01 string to G2553 after it entered the while(1) circulation body

    int main(void)
    {
     int Result = -1;
        unsigned char RegisterAddress;
        unsigned int NumberOfBytes;
        unsigned char *Buffer;
        unsigned int DataLength;

        WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

        DISABLE_INT;

        ClockInitialise();

        I2CInitialise();

        UARTInitialise();

    //    InitialisebqMaximo();

        ENABLE_INT;
        EnableUART();

        CommandStatus = COMMAND_PROCESSING;
    //    IE2 |= UCA0TXIE;
        while(1)
        {
         if (COMMAND_PROCESSING == CommandStatus)
         {
          ParseCommand();
          ProcessCommand();
         }
        }

  • OK, I only looked at your void UARTInitialise().
  • I found something, I am misguided by the UART program running on PC, the Parity, stop bit configuration does not work at all!
  • The ‘Multiprocessor Format’ sends out 9 data bits. The 9th bit replaces the regular UART STOP bit (or PARITY if enabled).
    Your PC software needs to support this format.

**Attention** This is a public forum