teensys 3.5 - serial2 problem

Status
Not open for further replies.

Mace Robotics

New member
Hello,

I use Teensys 3.5 and a serial IMU. My program work with SoftwareSerial but no with Serial2.
I use 9 and 10 pins (serial 2 on teensys 3.5)

Can anyone provide help for this problem ? thanks.

Code with Serial2 :

Code:
#define CMPS12 Serial2

const byte rxPin = 9;
const byte txPin = 10;

void IMU_init(void)
{
  Serial.println("Init IMU...");

  delay(1000);


  CMPS12.setRX(rxPin);
  CMPS12.setTX(txPin);

	CMPS12.begin(9600);

  // BAUD 38400
  CMPS12.write(0xA1);
  delay(500);
  
  CMPS12.begin(38400);

}

Code with SoftwareSerial :

Code:
SoftwareSerial CMPS12 = SoftwareSerial(9,10);

void IMU_init(void)
{
  Serial.println("Init IMU...");

  delay(1000);


  //CMPS12.setRX(rxPin);
  //CMPS12.setTX(txPin);

  CMPS12.begin(9600);

  // BAUD 38400
  CMPS12.write(0xA1);
  delay(500);
  
  CMPS12.begin(38400);

}

Thanks.
 
Note sure what part is not working … does first Serial2 print work but not the second or neither work?

Those pins 9 and 10 are the native primary pins for Serial2 so these lines in first code block are not needed or helping anything:
Code:
  CMPS12.setRX(rxPin);
  CMPS12.setTX(txPin);

As in the second code block they can/should be commented out.

That code is not a complete runnable sketch so not known how soon after setup() entry this code is running - it isn't clear if the Serial will be ready to print : Serial.println("Init IMU...");

Serial2 should be ready okay but … what device is on the other end? Has it had time to power up and is it ready for the first print?

Does SoftwareSerial use the standard N,8,1 delivered with the Serial2.begin()?
 
Status
Not open for further replies.
Back
Top