View previous topic :: View next topic |
Author |
Message |
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
Check if serial finished transmitting? |
Posted: Fri Mar 10, 2017 6:14 pm |
|
|
Hi,
I would like to know if there is a way to know if the software serial / hardware serial has finished transmitting?
I would like to make the PIC* TX pin switch to high impedance once finished.
Thanks!
*This is a broad question since I'm not targeting any specific PICs. _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1349
|
|
Posted: Fri Mar 10, 2017 8:04 pm |
|
|
Well software serial is pretty easy, it is finished when you finish using the function. Almost all HW periphs have a bit to tell you when transmitting is done. On the ones I work on, it is TRMT. |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Sat Mar 11, 2017 6:01 am |
|
|
You might want to add 'max xmt time' timer. If you know the maximum time it 'should' be, have a timer of say 2X that amount, run in the xmt function.
CCS has an example for receiving data in their FAQ section.
The idea is that if the timer times out, you get out of the function, a 'failsafe'.
Code is small, just a few bytes.
Just an idea for you....
Jay |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sat Mar 11, 2017 8:07 am |
|
|
caution:
UART translation chips still need to see the INPUT from the TX pin pulled HIGH - even if weakly to prevent false start bits from being sent. You can't put other signals into that connection and maintain transmission integrity.
do you understand the hardware issue you may be opening for yourself by trying to do two different hings with the TX pin ?
IMHO-
You have chosen a pretty poor pin for multiple duty in your circuit....
i hope your hardware skills are up to it.. |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sat Mar 11, 2017 10:50 am |
|
|
Thanks for your suggestions.
This was to try a rather old design idea (temtronic you might know) before RS422 and RS485 transceivers existed. I was surprised it rather actually work pretty well.
I designed a very very crude test (EE don't look!) to see how minimal (in parts) a multi-drop serial connection can go without affecting data integrity.
I was testing a test code in each 12F683 that would respond from a query of the master (PC) using nothing else than tri-state logic. This eliminated the need of the diodes in case I couldn't make the PIC TX pins float. They are all connected together directly on the 5V serial line to the Silabs CP2102 TTL to VCP chip.
Code: |
#include <12F683.h>
#FUSES INTRC_IO,NOWDT,NOPROTECT,NOMCLR
#use delay(clock=8000000)
#use rs232(baud=9600,xmit=PIN_A4,rcv=PIN_A5,FORCE_SW,ERRORS,FLOAT_HIGH)
void main()
{
unsigned int8 dummy;
while(1)
{
while(kbhit())
{
dummy=getc();
switch (dummy)
{
case '1' : printf("PIC #1 OK!");
break;
}
}
}
}
|
As long as the query is properly spaced in time (in my case it would be 10s between queries). I experienced no collision or garbage data.
From there I can work and add proper protection as suggested from the other related topic. --->>http://www.ccsinfo.com/forum/viewtopic.php?t=55996
Thanks all of you for the nice learning experience! _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
|