PaulStoffregen / AltSoftSerial

Software emulated serial using hardware timers for improved compatibility
http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
328 stars 131 forks source link

Teensy3.1 9600baud RX stops working after ~30s #10

Closed johnboiles closed 8 years ago

johnboiles commented 9 years ago

Running a super simple sketch that receives from the AltSoftSerial and outputs over Serial on Teensy3.1, I consistently get garbage data after 30-45s of use. Using AltSoftSerial 1.2 that came with the latest version of Teensyduino. Building the sketch in the Arduino IDE. Here's the sketch:

#include <Arduino.h>

#define DEBUG_LED LED_BUILTIN
#define OUTPUT_SERIAL Serial
#include <AltSoftSerial.h>
AltSoftSerial GPS_SERIAL;

void setup() {
    cli();

    pinMode(DEBUG_LED, OUTPUT);

    OUTPUT_SERIAL.begin(115200);
    GPS_SERIAL.begin(9600);

    sei();
}

void loop() {
    digitalWrite(DEBUG_LED, LOW);
    while (GPS_SERIAL.available()) {
        digitalWrite(DEBUG_LED, HIGH);
        uint8_t incomingByte = GPS_SERIAL.read();
        OUTPUT_SERIAL.write(incomingByte);
    }
}

Everything looks fine for anywhere from 15s to 1m 30s, then all the sudden I start to get garbage data (this line starts as valid NMEA data then explodes into garbage).

$GPGSV,4,1,13,04,12,311,39,11,16,312,37,14,77,164,40,18��b0,3��3C�G��Y�,��Lb1�N�I��i�b�2b�M)��i�        &b6���5,&�b1�   5&����j!�PG�*��4ib1&��,��,3b�L  �       L�      &b3&)6,�&���,4�)��ɥ6C�GP��Y,�     Lb5L�3)���&R4T
                                      $u1�Li7Mr��1,�)2��r�9�5��
                                                               �&�      0)�"�*�S5�:A�Rj����M�)��S�r�9��L�,1&�)��MbW     r��&b0�L�Lb,���C�GP��u,��       S�      �b�N    .0�S,K�*2L�H$u�A  0L��    b3S�    N��L�,L��)70�bWIb1L     .�j0IbM�I9��j�, 0R�QH$GuMA)��I�b�2�&��1,&b2L��)�b�3�&�L)�       )r5�    .����&�R0�M
                                                                                                                                   $�uS�bL��    �b1&�L�0)�bLb3Lb�)4,��,1b4�)8��b0�,3�L��3C�G��Y�,�)�b1�N�I�Mi�b�2b�M)30i� &b6���5�&�b1�   5&���j!�P�*��4ib1�&��,��,��L    ��L�    ��&)6�&���&,4�)��I�BC�GP��Y,�   Lb5L��)���R4��
��%�5(��L��     �bAi75�L���,�)2��r9�53��        �L�     1L��    �D*j                                                                          $u1�i7Mr��1,�)2��rN�������M�)�"��
                                                                    ��AV��b�T�M r��Lr,� 5�i��%��C�GP����&r0i7Mr��2,�)2��r�9�5&��&)�     �       6�      .&�,K�r5��,�%
                                                                                                                                                                     5!:A�G��,Aib2��&     �b�5b2I1,�L�b1�i2)�bLb,L��      r�)r3&  5C�G��Y,��Lb0��i���,1b�i�&i�    Lb7)64�0,�L,3M��i1�5�

Rebooting the device by reprogramming it or hitting reboot in the Teensy UI solves the problem temporarily, so it's definitely not an issue with the GPS.

PaulStoffregen commented 9 years ago

Which GPS module are you using? I have a few here, but I believe they're all 4800 baud. If I'm ever going to investigate and fix this, first I need to get the right hardware setup to reproduce the problem.

johnboiles commented 9 years ago

I'm using a 5V uBlox-6 GPS from SparkFun I had left over from a past project. Switched the GPS to Serial3 and it's been working great for the past day so unlikely to be an issue with the GPS.

BTW, really love that the Teensy 3.1 pins are 5V tolerant!

PaulStoffregen commented 9 years ago

I ordered one of those GPS modules from Sparkfun.

johnboiles commented 9 years ago

Awesome, look forward to hearing if you hit the same thing.

On Mon, Nov 3, 2014 at 8:40 AM, Paul Stoffregen notifications@github.com wrote:

I ordered one of those GPS modules from Sparkfun.

— Reply to this email directly or view it on GitHub https://github.com/PaulStoffregen/AltSoftSerial/issues/10#issuecomment-61506451 .

PaulStoffregen commented 8 years ago

I've fixed several subtle bugs and added support for slower baud rates.

Please give the latest code a try and let me know if it resolves this issue for you?

PaulStoffregen commented 8 years ago

I'm pretty sure the recent fixes solve this problem, so I'm closing this issue.

If there's still a problem, please open a new issue. Remember to always post code & hardware details necessary to reproduce the problem.

johnboiles commented 8 years ago

@PaulStoffregen sounds good. I don't have the same project put together anymore (or rather, I rev'd the pcb to use Serial3). Not sure if I'll have need of 9600 baud with AltSoftSerial again :) Thanks for all your work on Teensy