Jump to content
43oh

Stellaris (LM4F120) multiple UART problem


Recommended Posts

I'm working with the stellaris launchpad on energia (version 1010E0009).  I need to use two hardware serial ports, and I'm finding that it does not work.  I've made a VERY simple sketch that demonstrates this behavior:

 

#include "Energia.h"

#include "HardwareSerial.h"
 
#define RED_LED 30
#define GRN_LED 39
#define BLU_LED 40
 
#define RED_PWM PF_1
#define GRN_PWM PF_2
#define BLU_PWM PF_3
 
HardwareSerial serialZero  = HardwareSerial(0);
HardwareSerial serialOne   = HardwareSerial(1);
//HardwareSerial serialTwo   = HardwareSerial(2);
//HardwareSerial serialThree = HardwareSerial(3);
//HardwareSerial serialFour  = HardwareSerial(4);
//HardwareSerial serialFive  = HardwareSerial(5);
//HardwareSerial serialSix   = HardwareSerial(6);
//HardwareSerial serialSeven = HardwareSerial(7);
 
void setup() {
  pinMode(RED_LED, OUTPUT);
  pinMode(GRN_LED, OUTPUT);
  pinMode(BLU_LED, OUTPUT);
 
  serialZero.begin(9600);
  serialOne.begin(9600);
//  serialTwo.begin(9600);
//  serialThree.begin(9600);
//  serialFour.begin(9600);
//  serialFive.begin(9600);
//  serialSix.begin(9600);
//  serialSeven.begin(9600);
}
 
void loop() {
  static boolean value = HIGH;
  
  serialZero.print("Serial port : ");
  serialOne.print("Serial port : ");
//  serialTwo.print("Serial port : ");
//  serialThree.print("Serial port : ");
//  serialFour.print("Serial port : ");
//  serialFive.print("Serial port : ");
//  serialSix.print("Serial port : ");
//  serialSeven.print("Serial port : ");
  serialZero.println(0);
  serialOne.println(1);
//  serialTwo.println(2);
//  serialThree.println(3);
//  serialFour.println(4);
//  serialFive.println(5);
//  serialSix.println(6);
//  serialSeven.println(7);
 
  delay(100);
 
  if (value == 1) {
    value = 0;
    digitalWrite(RED_LED, HIGH);
  } else {
    value = 1;
    digitalWrite(RED_LED, LOW);
  }
}

 

 

When every port but one is commented out, the program runs fine.  The light blinks, serial data moves, etc.  When more than one is created, the first round of data goes out to each port, but it crashes somewhere.  Often, the first few characters of the second loop begin printing on port zero.  This doesn't happen when the delay(100) is in there.  I'm not sure if this is a known bug or not, but it seems like the hardware serial library should be able to have multiple instances and work fine.

 

 

Ideas?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...