Jump to content
Sign in to follow this  

Serial1 not working on MSP432P401R

Recommended Posts

Hi, I am trying to make a UART connection with a  device from serial1 in MSP432. It isn't working as i cannot see anything printing on my serial monitor (I am trying to print the data stored in global variables using serial/USB).


Wherein the same code works fine on MSP430 or TM4C1294 devices.

I have double checked my wiring connections.. P3.2, P3.3 for RX, TX.


Can anyone here help me resolve this issue or point out where im going wrong.. Please find the code below

  // Microchip MCP39F501 Power Monitor TI Interface Sample Code

    #define ACK 0x06
    #define NACK 0x15
    #define CSFAIL 0x51
    int OK1_Count = 0;      // Success/No Success Counter for Reg Read 0x0002
    int NOK1_Count = 0;
    byte Xmit_Dly = 2;      // Transmit Delay between bytes, in msec
    byte Header;            // Received ACK/NACK/CSFAIL byte
    byte Byte_Count;        // Reveived Byte count
    byte CurrentRMS_LL;      // 0x0004 CurrentRMS 
    byte CurrentRMS_L;       // 0x0005 CurrentRMS
    byte CurrentRMS_H;       // 0x0006 CurrentRMS
    byte CurrentRMS_HH;      // 0x0007 CurrentRMS
    byte VoltageRMS_L;       // 0x0008 Voltage RMS
    byte VoltageRMS_H;       // 0x0009 Voltage RMS
    byte ActivePower_LL;     // 0x000A ActivePower
    byte ActivePower_L;      // 0x000B ActivePower
    byte ActivePower_H;      // 0x000C ActivePower
    byte ActivePower_HH;     // 0x000D ActivePower
    byte ReactivePower_LL;   // 0x000E ReactivePower
    byte ReactivePower_L;    // 0x000F ReactivePower
    byte ReactivePower_H;    // 0x0010 ReactivePower
    byte ReactivePower_HH;   // 0x0011 ReactivePower
    byte ApparentPower_LL;   // 0x0012 ApparentPower
    byte ApparentPower_L;    // 0x0013 ApparentPower
    byte ApparentPower_H;    // 0x0014 ApparentPower
    byte ApparentPower_HH;   // 0x0015 ApparentPower
    byte PowerFactor_L;      // 0x0016 PowerFactor
    byte PowerFactor_H;      // 0x0017 PowerFactor
    byte Freq_L;      // 0x0016 Frequency
    byte Freq_H;      // 0x0017 Frequency
    byte CheckSum;
    byte CalculatedCS;
    float CurrentRMS;        // Current RMS
    float VoltageRMS;        // Voltage RMS
    float ActivePower;       // Active Power
    float ReactivePower;     // Reactive Power
    float ApparentPower;     // Apparent Power
    float PowerFactor;       // Power Factor
    float Freq;              // Frequency
  void setup() {
    Serial.println("Entering Loop ");
  void loop() {
    if (RegRead0x0004()) { OK1_Count++; } else { NOK1_Count++; }

    Serial.print("MCP39F501 DEMO BOARD   : "); 
    Serial.print("RMS Current            : "); Serial.print(CurrentRMS*0.0001,4); Serial.println(" A");
    Serial.print("RMS Voltage            : "); Serial.print(VoltageRMS*0.1,1); Serial.println(" V");
    Serial.println("DATA COMMUNICATION");
    Serial.print("1st frame counts: OK="); Serial.print(OK1_Count,DEC);
    Serial.print(", Not OK="); Serial.println(NOK1_Count,DEC);
  bool RegRead0x0004(void) {
  // Parse the data returned from the meter
    if (Serial1.available()) {
      Header = Serial1.read();
      Byte_Count = Serial1.read();
      CurrentRMS_LL = Serial1.read();
      CurrentRMS_L = Serial1.read();
      CurrentRMS_H = Serial1.read();
      CurrentRMS_HH = Serial1.read();
      VoltageRMS_L = Serial1.read();
      VoltageRMS_H = Serial1.read();
      ActivePower_LL = Serial1.read();
      ActivePower_L = Serial1.read();
      ActivePower_H = Serial1.read();
      ActivePower_HH = Serial1.read();
      ReactivePower_LL = Serial1.read();
      ReactivePower_L = Serial1.read();
      ReactivePower_H = Serial1.read();
      ReactivePower_HH = Serial1.read();
      ApparentPower_LL = Serial1.read();
      ApparentPower_L = Serial1.read();
      ApparentPower_H = Serial1.read();
      ApparentPower_HH = Serial1.read();
      PowerFactor_L = Serial1.read();
      PowerFactor_H = Serial1.read();
      Freq_L = Serial1.read();
      Freq_H = Serial1.read();
      CheckSum = Serial1.read();     
    Serial.print("Cehcksum Received:  ");
    // Calculate the expected CheckSum
    CalculatedCS = (byte)((int)( Header + Byte_Count +
                    CurrentRMS_LL + CurrentRMS_L + CurrentRMS_H + CurrentRMS_HH + 
                    VoltageRMS_L + VoltageRMS_H +
                    ActivePower_LL + ActivePower_L + ActivePower_H + ActivePower_HH +
                    ReactivePower_LL + ReactivePower_L + ReactivePower_H + ReactivePower_HH +
                    ApparentPower_LL + ApparentPower_L + ApparentPower_H + ApparentPower_HH +
                    PowerFactor_L + PowerFactor_H +
                    Freq_L + Freq_H +
     Serial.print("Checksum Calculated:  ");
    // Check for ACK, correct byte count and CheckSum matches expected checksum
    if ((Header == 0x06) ){//&& (Byte_Count == 0xD) && (CheckSum == CalculatedCS)) {
      Serial.println("IM HERE");
      CurrentRMS = ((unsigned long)(CurrentRMS_HH << 24) + (unsigned long)(CurrentRMS_H << 16) + (unsigned long)(CurrentRMS_L << 8) + (unsigned long)(CurrentRMS_LL));
      VoltageRMS = ((unsigned int)(VoltageRMS_H << 8) + (unsigned int)(VoltageRMS_L)) ;
      return true;
    else return false;
  void WriteByte(byte _wbyte) {
  void WriteByteND(byte _wbyte) {
  void ClearBuffer(void) {
      while(Serial1.available()) char _f = Serial1.read();

Share this post

Link to post
Share on other sites

Hi @@MSP432,


Can you explain what you mean by


It isn't working as i cannot see anything printing on my serial monitor (I am trying to print the data stored in global variables using serial/USB).

I pasted the code in a MSP432 and Energia V18 and it is printing to the serial monitor.  Of course all the data is 0 because I don't have a sensor hooked up.  I attached my logic analyzer to P3_3 and I see serial1 output.

Share this post

Link to post
Share on other sites

So when i run the code.  if (Serial1.available())  this statement always FAIL. Program never enters into that if loop, it is just skipping that. As a result the Serial1.end(); after the IF loop is halting the program there and the loop breaks. As a result i cannot see anything print on my serial monitor.


But the same code works well with MSP430.


What would the issue be? Should i change some jumper settings on my MSP432 for the Serial1 to work. I tried on multiple MSP432 boards both red and black nothing worked.

Share this post

Link to post
Share on other sites



Try hooking a jumper between P3_2 and P3_3, then run this sketch...

void setup() {

void loop() {
  if (Serial1.available()) {
    int inByte = Serial1.read();

If it runs, then at least your LaunchPad is sending and receiving Serial1.  It worked for me with Energia V18 and a black MSP432. 


Past that it is just guessing for me since you say it works on other LaunchPads and I don't have the sensor.  Try getting hold of an oscilloscope or logic analyzer so you can see the signals.


Edit:  Posting a picture of your setup may help someone diagnose the problem

Share this post

Link to post
Share on other sites

The datasheet for the MCP39F501 says the default baud rate is 4.8 kbps.  Are you sure the baud rate is right?  It seems that the LP is sending data but the MCP39F501 is not responding.


EDIT:  In your photo it is not evident that they share ground

Share this post

Link to post
Share on other sites

Ground!! Thats a big question even i had. But luckly it was working (I dnt knw how its referencing the signal though) as expected on MSP430 and TM4C1294.

When i look at the higher version MCP39F511, this piece has a ground connection pin available from MCP to MSP.


But the MCP board i am using doesn't have any ground pin to connect to.


And yes my baud rate is 4.8kbps (code snippet attached)

bool RegRead0x0004(void) {

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this