SoftwareSerial

Please do not post requests
konczakp
Posts: 191
Joined: Thu Jul 14, 2016 4:17 pm

Re: SoftwareSerial

Post by konczakp » Tue Nov 08, 2016 8:57 pm

I was able to get this running with this one: https://github.com/wingspinner/SoftwareSerialSTM32

konczakp
Posts: 191
Joined: Thu Jul 14, 2016 4:17 pm

Re: SoftwareSerial

Post by konczakp » Fri Dec 02, 2016 12:35 pm

Another problems :/

There is some kind of problem with this library. It seems that it relay on the cpu cycles or whatever. Sometimes it is working and sometimes not. Sometimes it is enough to add 1 line to the code in main loop and sometimes a delay need to be added. For example this code is working:

Code: Select all

#include <SoftSerialSTM32.h>
#include <string.h>
#include <SPI.h>

#define SIM800_TX_PIN PC14
#define SIM800_RX_PIN PC15
SoftSerialSTM32 mySerial(SIM800_RX_PIN, SIM800_TX_PIN);

#define RFID_TX_PIN PA4
#define RFID_RX_PIN PA5
SoftSerialSTM32 mySerialRFID(RFID_RX_PIN, RFID_TX_PIN);

int x = 100;

void setup() {
  
  Serial.begin(115200);
  mySerial.begin(9600);
  //mySerialRFID.begin(9600);
  
}

void loop() {
  delay(x);
  
  String strsim = ""; 

  if (mySerial.available () > 0) {

    strsim = mySerial.readStringUntil('\n');

    
      Serial.print("SIM800L: ");
        for (int xi=0; xi<strsim.length(); xi++) {
          Serial.print(char(strsim[xi]));
        }
        Serial.print("\n");

    
  }
  
  

  String strser = ""; 

  while (Serial.available () > 0) {
    strser += char(Serial.read ());
  }
  if (strser != ""){
    if (strser.startsWith("test")){ //check hw serial response
      Serial.println("serial ok");
//    } else if (strser.startsWith("D")){ //change delay
//      strser.replace("\n","");
//      strser.replace("\r","");
//      strser.replace("D","");
//      int outint = strser.toInt();
//      x = outint;
//      Serial.println("New delay: "+String(outint));
//      mySerial.print("AT"); //send command after delay change and wait for answer
    } else {
       mySerial.print(strser); //send command
    }
  }
  
 
}
and if I want to add second software serial by uncommenting line : mySerialRFID.begin(9600); then softserial stops to work and adding delay or lines of code is not helping. First I thought that it is out of synchronisation so I started to count cpu cycles like here http://electronics.stackexchange.com/qu ... rduino-avr but I've stuck and Im unable to get this working and I really need to get those software serial to work. Any suggestions? Changing UART speed doesn't make any progress/change. Maybe anyone has a working library ?

konczakp
Posts: 191
Joined: Thu Jul 14, 2016 4:17 pm

Re: SoftwareSerial

Post by konczakp » Fri Dec 09, 2016 3:04 pm

Any idea ??

User avatar
ahull
Posts: 1650
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: SoftwareSerial

Post by ahull » Sat Dec 10, 2016 12:10 am

Does SoftwareSerial rely on timers and/or interrupts for the accuracy of its bps, if so, then you may be attempting to use the same timer/interrupt twice. Just a thought, and since its nine minutes past midnight here, probably not one of my better thoughts... :?
- Andy Hull -

User avatar
RogerClark
Posts: 7458
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: SoftwareSerial

Post by RogerClark » Sat Dec 10, 2016 12:19 am

Just as a matter of interest...

Why do you need to use software serial. There are plenty of hardware serial ports available.

stevestrong
Posts: 1817
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: SoftwareSerial

Post by stevestrong » Sat Dec 10, 2016 8:10 am

RogerClark wrote:Why do you need to use software serial. There are plenty of hardware serial ports available.
I would also use the HW serial ports.
Looking to your other posts where I2C is involved, if no free HW interface available, then I would use bit-banged (software) I2C to communicate with sensors, but anyway use HW serial to communicate between processors.

konczakp
Posts: 191
Joined: Thu Jul 14, 2016 4:17 pm

Re: SoftwareSerial

Post by konczakp » Sat Dec 10, 2016 9:25 am

I have plenty of sensors and devices to communicate with. When I use TFT ILI9341 with touch screen and SD, nrf24l01+, SIM800L, ESP8266, BMP085, Humidity sensor, energy monitor, 433 RF, RFID, etc etc ... then using only one maple is not enough. Second thing is that I'm trying to use hardware interfaces to get highest available speed because longer sketch code means slower speed of maple and maple is not able to receive everything from devices like UART at high speed. But sometimes it is impossible to use only hardware as in my case. That is why I'm trying to get the software serial working and also I2C and other stuff. As in this thread http://www.stm32duino.com/viewtopic.php?f=13&t=864 I'm using the first one delay driven software serial because interrupt driven was not working not only for me.

User avatar
mrburnette
Posts: 1883
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: SoftwareSerial

Post by mrburnette » Sat Dec 10, 2016 2:24 pm

konczakp wrote:I have plenty of sensors and devices to communicate with. When I use TFT ILI9341 with touch screen and SD, nrf24l01+, SIM800L, ESP8266, BMP085, Humidity sensor, energy monitor, 433 RF, RFID, etc etc ... then using only one maple is not enough.
IMO, you have selected the wrong hardware.

As a retired systems architect, I hear your story all the time in different forums surrounding microcontrollers. You are trying to use software to "grow" hardware capability. The results are never optimum.

It is not my job to tell you that one project should not have all of that external hardware. But having all of that external hardware hanging off of a Maple Mini is not wise.

Either move upstream in the microcontroller pinout capabilities, or learn how to connect multiple Maple-Mini controllers to achieve a true system design. In fact, some of the low bandwidth sensors are perfect for 8-bit uC chips.

Google this for a start:
interconnect multiple microcontrollers


Ray

konczakp
Posts: 191
Joined: Thu Jul 14, 2016 4:17 pm

Re: SoftwareSerial

Post by konczakp » Sat Dec 10, 2016 7:04 pm

I was using multiprocessors platform with Atmega128P and I don't want to do that again. I'm porting all my code from that multiprocessors platform to maple because making changes was an horror for me. Changing one thing was bringing other changes on other processors etc. Maybe I had badly designed platform ... i don't know. Maybe I could go up with the architecture to get more I/O pins but unfortunately at the time I've started to port my project I didn't have that knowledge. So now I have to stick what I have chosen. So now I have a problem with this software serial so If anyone could help I will appreciate that :)

BTW : Now I'm also using multiprocessors with I2C communication (trying to use as it can be seen in other thread) but this time in different way :)

User avatar
Rick Kimball
Posts: 1057
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: SoftwareSerial

Post by Rick Kimball » Sat Dec 10, 2016 7:28 pm

If you want to use that code, you might be able to replace the tunedDelay() function with something that uses the approach I posted about here:

http://www.stm32duino.com/viewtopic.php ... ycle+delay

Although I'm sure using a timer would be a better approach if you really want more than 3 uarts. How many uarts do you actually need?

-rick
-rick

Post Reply