Using only TX from Serial Port

Status
Not open for further replies.

tenkai

Well-known member
Hello!

I made a board where I am using pin 0 to drive some neopixels, but at the same time I want to use pin 1 (as Serial1 TX1) to transmit data to a serial device I have.

I can control the Neopixels fine, and I can send Serial data just fine, however once I begin to send Serial data over TX1, I can no longer control the Neopixels.

Upon investigating with a logic analyzer, I found that after I begin to send data over TX1, pin 0 (which is RX1) gets pulled high. Even if I write a LOW to pin 0, it stays high.

Is this expected behavior? Anyone know of a way I can use pin 1 as TX1, while still using pin 0 as a regular GPIO pin?

Screen Shot 2016-02-02 at 1.33.16 PM.png

Thanks!
T
 
PS, it is labeled as MOSI and MISO, but the label numbers are respective to the pin numbers.
 
Here is some sample code that reproduces the issue.

Expected behavior would be for the pixels to wipe blue, send a note on signal to my SAM2695 library, then send a colorwipe red to the neopixels:

Code:
#include "Zetaohm_SAM2695.h"
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(20, 0, NEO_GRB + NEO_KHZ800);
Zetaohm_SAM2695 sam2695;


void setup(){

  pixels.begin();
  pixels.setBrightness(35);

}

void loop(){
   colorWipe(pixels.Color(0,255,255), 10);
   sam2695.noteOn(1, 1, 127);
   colorWipe(pixels.Color(255,0,0), 10);

}


void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<pixels.numPixels(); i++) {
    pixels.setPixelColor(i, c);
    pixels.show();
    delay(wait);
  }
}
 
Ah, I answered my own question!

I have a sam2695.begin() subroutine which was automatically called if the library had not already been initialized. By initializing the Serial port before initializing the neopixels explicitly, I am able to ensure the neopixels can talk to the Teensy while sending data on TX1
 
Can you provide code for the sam2695.noteOn function?

I wonder if Serial.write resets the multiplexer back to allowing pin 1 to be controlled by the UART.
 
Ah, I answered my own question!

I have a sam2695.begin() subroutine which was automatically called if the library had not already been initialized. By initializing the Serial port before initializing the neopixels explicitly, I am able to ensure the neopixels can talk to the Teensy while sending data on TX1

Scrap my response then haha. Yeah that will do it. Serial.begin sets the multiplexer up for the serial output, so will cause that issue =]
 
Status
Not open for further replies.
Back
Top