CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Check if serial finished transmitting?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

Check if serial finished transmitting?
PostPosted: Fri Mar 10, 2017 6:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Mar 10, 2017 8:04 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Mar 10, 2017 10:08 pm     Reply with quote

Thanks... found out a nice built-in option with the #use rs232 directive.

Float_High is exactly what I was looking for. Works on soft and hardware serial.
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 6:01 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Sat Mar 11, 2017 8:07 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Mar 11, 2017 10:50 am     Reply with quote

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! Smile
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group