You can use a hardware interrupt to act as a hardware serial receive. Hook your TX from your device to a hardware interrupt. Set the edge detect to falling. Set that port/pin to SoftSerial RX. Set any other pin to SoftSerial TX.
This is with my new micro controller so it will probably need modying for your device, but I have used it on an older model that had hardware interrupts and it worked.
#chip 16f19176, 32#include<SoftSerial.h>'=======Simulatehardwarerx==============================#define SER1_TXPORT PORTB#define SER1_TXPIN 1#define SER1_RXPORT PORTB 'needs to be a port and pin#define SER1_RXPIN 0 'that is an interrupt#define SER1_BAUD 9600#define SerInPort1 PORTB.0#define SerOutPort1 PORTB.1'SetpindirectionsdirSerOutPort1OutDirSerInPort1InsetSerOutPort1on#define SOFTWARE_BUFFER1 60dimrxbuf1asstring*SOFTWARE_BUFFER1'usesastringforabufferdimrxflag1asInteger'flagtotellwhennewcharrxflag1=0rxbuf1(0)=0INTEDG=0'InterruptonfallingedgeOnInterruptExtInt0CallRx1Int'===================================doifrxflag1=1Then'newcharacterinbufferrxflag1=0'resetbufferflag'-----startcharis?andendcharisCR-----------if(rxbuf1(1)="?")and(rxbuf1(rxbuf1(0))=13)Then'completemessagerxbuf1(1)="!"'changestartcharwait500us'needbriefdelaybeforesendSer1Printrxbuf1rxbuf1(0)=0'clearbufferendifendifloopsubRx1Intrxbuf1(0)++'inccharlocationrxbuf1(rxbuf1(0))=Ser1Receive'storecharinstringvariableifrxbuf1(0)=SOFTWARE_BUFFER1then'ifendofbufferrxbuf1(0)=0'startoverendifrxflag1=1'setflagfornewcharacterendsub
Later,
Clint
Last edit: Clint Koehn 2018-07-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Simple, Elegant and addresses the main downfall of SoftSerial.
I, and I am sure many others, will find this both useful and inspirational.
Thanks for sharing.
Cheers
Chris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the kind words Chris. I have a chip that has 2 hardware serial ports but I needed a third one. One radio went to the computer, one was for a sensor board I made and I needed a third one for a 4D display.
Later,
Clint
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can use a hardware interrupt to act as a hardware serial receive. Hook your TX from your device to a hardware interrupt. Set the edge detect to falling. Set that port/pin to SoftSerial RX. Set any other pin to SoftSerial TX.
This is with my new micro controller so it will probably need modying for your device, but I have used it on an older model that had hardware interrupts and it worked.
Later,
Clint
Last edit: Clint Koehn 2018-07-27
Simple, Elegant and addresses the main downfall of SoftSerial.
I, and I am sure many others, will find this both useful and inspirational.
Thanks for sharing.
Cheers
Chris
Thanks for the kind words Chris. I have a chip that has 2 hardware serial ports but I needed a third one. One radio went to the computer, one was for a sensor board I made and I needed a third one for a 4D display.
Later,
Clint