Pages: [1]   Go Down
Author Topic: AltSoftSerial and Arduino MICRO  (Read 569 times)
0 Members and 1 Guest are viewing this topic.
Austin, TX
Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've got a program that's reading XBee data via SoftwareSerial on an Arduino MICRO.  But I'm having some problems when also communicating with a PowerSSR Tail via interrupts. XBee checksums are failing, so it looks like XBee data is getting lost. I figured I'd try AltSoftSerial to see if that would help.

My first problem was that AltSoftSerial (latest from http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html) doesn't compile out of the box for the MICRO.  So I updated the config/known_boards.h file in the AltSoftSerial library to treat the MICRO like a Leonardo, using the __AVR_ATmega32U4__ define.

Code:
#elif defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_LEONARDO) || defined(__AVR_ATmega32U4__ )

  //#define ALTSS_USE_TIMER1
  //#define INPUT_CAPTURE_PIN 4  // receive
  //#define OUTPUT_COMPARE_A_PIN 9 // transmit
  //#define OUTPUT_COMPARE_B_PIN 10 // unusable PWM
  //#define OUTPUT_COMPARE_C_PIN 11 // unusable PWM

  #define ALTSS_USE_TIMER3
  #define INPUT_CAPTURE_PIN 13 // receive
  #define OUTPUT_COMPARE_A_PIN 5 // transmit

But when I change the XBee from using SoftwareSerial to AltSoftSerial, I'm not getting any data from the XBee.

The old working code is:
Code:
#define XBEE_RX_PIN 11      // Software Serial can only use some pins on the Micro for RX, 11 is one of the lucky ones.
#define XBEE_TX_PIN 12
SoftwareSerial xbeeSerial(XBEE_RX_PIN, XBEE_TX_PIN);

// Set pins to outputs and initial states
void setup() {
  Serial.begin(9600);
  xbeeSerial.begin(9600);
  xbee.setSerial(xbeeSerial);
  // ...

The new code is:
Code:
// Uses hard-wired pins, same as leonardo: 13 for RX, 5 for TX.
AltSoftSerial xbeeSerial;

// same setup()

After moving the RX and TX wires to 13 and 5, respectively, I'm no longer getting data from the XBee.  Switching the RX and TX wires between the pins didn't help.  I'm getting the RSS light on the XBee Explorer during transmission, so I know that data's getting to the XBee.

Has anyone gotten AltSoftSerial to work on the MICRO?  How?  Thanks!

Side question: I found the __AVR_ATmega32U4__ define by passing the -dM -E flags into a copied avr compile statement.  Which curiously does not list the ARDUINO_AVR_LEONARDO define when the board is set to Leonardo, although known_boards.h compiles when the board is set to Leonardo.  Where is ARDUINO_AVR_LEONARDO set?  ARDUINO_AVR_MICRO isn't defined when the board is set to Micro. Is there another define to use for the MICRO board?
Logged

Austin, TX
Offline Offline
Newbie
*
Karma: 1
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Never mind. The steps above are indeed the ones used to get AltSoftSerial working with the MICRO. As long as you don't later open pin 13 for output for LED debugging. Doh!

Meanwhile, if there's a better test to use for the MICRO in known_boards.h besides
Code:
defined(__AVR_ATmega32U4__)
I'm all ears.  Thanks.
Logged

Pages: [1]   Go Up
Jump to: