Jump to content
Sign in to follow this  
hpux735

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?

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  

×