Author Topic: Uart-Problem  (Read 1905 times)

m6vitek

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Uart-Problem
« on: January 23, 2015, 03:27:58 PM »
Hello Friends,
i have a problem with the UART-interface. I need 2 serial-interfaces (1 for debugging) in my project and there for I've written a small function to switch between the pins. The problem is that I become 0xFF on the UART even if nothing transmitted in the main loop. When I transmit some data, 0xFF will be attached to the begin of transmitted sentence. Here is the code I've used. I hope, somebody can explain me that issue.

P.S.: This problem only appears at higher baud-rates (i.e. 115200).

Code: [Select]
static const int RXPin = 2, TXPin = 3;

static int switch_flag;



// Switch  Serialports
void serial_switch(int nr)
{
  int ret;
  Serial.flush();
  Serial.end();
  delay(100);
  if (nr==1)
  {
    Serial.begin(115200);
    ret=1;
  }
  else
  {
    Serial.begin(9600,RXPin,TXPin);
    ret=2;
  }
  switch_flag=ret;
  delay(10);
}


void setup()
{

}

void loop()

  if (switch_flag==2){
    serial_switch(1);
  }
  else {
    serial_switch(2);
  }
delay(1);
}


Attached is a screenshot how it looks like in HTerm after uploading the upper sketch.
« Last Edit: January 24, 2015, 02:38:02 AM by m6vitek »

mkay

  • RFduino Team
  • *****
  • Posts: 405
  • Karma: +15/-0
    • View Profile
Re: Uart-Problem
« Reply #1 on: January 29, 2015, 02:03:32 PM »
Hi m6vitek, I will try to replicate this on my end...

m6vitek

  • RFduino Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Uart-Problem
« Reply #2 on: February 07, 2015, 02:37:43 PM »
Hi m6vitek, I will try to replicate this on my end...
That would be great, Mkay. I have tried it on different Rfduinos but the problem is the same. Already in the Serial.begin(115200) he prints 0xFF out even though he has not to print out anything. If the baudrate is set up to 9600, everything works fine. I also can not read incoming data from GPS receiver at baudrates higher than 19600 baud with the tinygps++ library. At lower (9600) baud it is possible. Arduino nano does it even at 115 kbaud, so what can be done to overcome this problem?
« Last Edit: February 09, 2015, 12:37:17 PM by m6vitek »

 

anything