I'm using the UART serial port at 115200bps and software serial at 9600bps.
All is fine if I only use the UART serial but when I start using one and then immediately try and use the software serial my chip resets.
I am doing things like:
Serial.print("hello");
Serial.write(13);
delay(20);
softwareSerial.print("stuff");
Any ideas?
I've tried using the software serial at 115200bps too but that doesn't help.
Any ideas?
Post your code, using code tags
Is it not Serial.write() and not Serial.send() ?
The pertinent pieces of code:
#include <SoftwareSerial.h>
#define SRB_SOFTWARESERIAL_RX 10
#define SRB_SOFTWARESERIAL_TX 11
SoftwareSerial SRB_SoftSerial = SoftwareSerial(SRB_SOFTWARESERIAL_RX, SRB_SOFTWARESERIAL_TX);
enum eScreenDisplayType
{
SCREENDISPLAY_COLOUR_BLACK = 0,
SCREENDISPLAY_COLOUR_RED = 1,
SCREENDISPLAY_COLOUR_GREEN = 2,
SCREENDISPLAY_COLOUR_ORANGE = 3
};
#define DISPLAY_SCREEN_WIDTH 80
#define DISPLAY_SCREEN_HEIGHT 8
void setup()
{
SRB_SoftSerial.begin(9600);
SRB_SoftSerial.listen();
Serial.begin(115200);
}
void loop()
{
screenDisplay("hello world", SCREENDISPLAY_COLOUR_BLACK, SCREENDISPLAY_COLOUR_RED);
SRB_SoftSerial.print("softwareserial");
}
void screenDisplayInternal(char* message)
{
Serial.print(message);
Serial.write(13);
Serial.flush();
delay(20);
}
void screenPaint()
{
screenDisplayInternal("paint");
}
void screenClear()
{
screenDisplayInternal("clear");
}
void screenDisplay( const char* message,
int background,
int foreground)
{
char __dsp[512];
// text
// colour 0 = black, 1 = red, 2 = green, 3 = orange
// pos x, y - bottom left
if(background == SCREENDISPLAY_COLOUR_BLACK)
{
screenClear();
}
else
{
snprintf(__dsp, 512, "rect %d 0 7 %d %d", background, DISPLAY_SCREEN_WIDTH, DISPLAY_SCREEN_HEIGHT);
screenDisplayInternal(__dsp);
}
snprintf(__dsp, 512, "text %d 0 7 \"%s\"", foreground, message);
screenDisplayInternal(__dsp);
screenPaint();
}
Do you have stack space for a 512 byte array?