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

strange situation function putc();

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



Joined: 21 Sep 2010
Posts: 163

View user's profile Send private message

strange situation function putc();
PostPosted: Tue Dec 16, 2025 8:07 am     Reply with quote

hy
I have situation with putc()
putc(0) ->0b00000000
putc(1) ->0b00000001
putc(2) ->0b00000010
putc(3) ->0b10000001
putc(4) ->0b00000100
putc(5) ->0b01000001
putc(6) ->0b10000010
putc(7) ->0b11000001
and so on...


#include <12F629.h>

#FUSES NOWDT
#FUSES NOMCLR
#FUSES NOBROWNOUT
#FUSES INTRC_IO
#FUSES NOPUT
#use delay(clock=4MHz)
#use rs232(baud=9600,parity=N, xmit=PIN_A5, rcv=PIN_A2, bits=8, FORCE_SW)
what is wrong?
temtronic



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

View user's profile Send private message

PostPosted: Tue Dec 16, 2025 8:32 am     Reply with quote

What is on the receiving end of the transmission?
Do you have proper RS-232 level translators" ( MAX232 ? )
Ttelmah



Joined: 11 Mar 2010
Posts: 20003

View user's profile Send private message

PostPosted: Tue Dec 16, 2025 8:47 am     Reply with quote

Also, you are using a software UART. What _else_ is the code doing?. If
(for example), you have an interrupt being used, and this happens when
sending, puts will stop, with the serial line not changing, until the code
returns from the interrupt, Result extra unwanted bots in what is sent....
If you are using an interrupt, the puts needs to have the DISABLE_INTS
option.
Also be aware, that to receive, your code needs to be sitting waiting for
the character to come.
nailuy



Joined: 21 Sep 2010
Posts: 163

View user's profile Send private message

PostPosted: Tue Dec 16, 2025 10:37 am     Reply with quote

I have:
if(kbhit()){}
comunication on single wire...
i think problem is from kbhit.
how to disable during send..?
temtronic



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

View user's profile Send private message

PostPosted: Tue Dec 16, 2025 11:49 am     Reply with quote

You really should post your entire program... it'll be a LOT easier to help when we see the whole code !
nailuy



Joined: 21 Sep 2010
Posts: 163

View user's profile Send private message

PostPosted: Tue Dec 16, 2025 5:12 pm     Reply with quote

problem solved

#use rs232(baud=9600, rcv=PIN_A0, bits=8, parity=N, stream=RX_SERIAL)

#use rs232(baud=9600, xmit=PIN_A1,bits=8, parity=N, INVERT, stream=TX_SERIAL)

because of output with transistor same wire was inverted signal.

so now is solved.

thank you.
temtronic



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

View user's profile Send private message

PostPosted: Tue Dec 16, 2025 5:54 pm     Reply with quote

glad it's solved

FWIW....
Historically 'RS-232' had line drivers ( 1488) and line receivers ( 1489), that allowed of +-12v signals between the two devices.They invert the signals. MAX232 is a newer, combination chip .it's probably 40 years old now.....Over time 'RS-232' has come to mean 'a UART compatible signal 3 or 5 volt' AND no 'driver chip' needed. Somehow when 'they' changed the spec from DB-25 connectors to DE-9 connectors ,'they' also swapped the TXD and RXD pins ! 2-> 3, and 3-> 2. That caused me a lot of grief.Used to have dozens of serial devices on several systems...
nailuy



Joined: 21 Sep 2010
Posts: 163

View user's profile Send private message

PostPosted: Tue Dec 16, 2025 7:44 pm     Reply with quote

yes, thank you.
hardware as diagram, have only 3 wires between cpu and dedicated chip (purged id): 5v, data, and 0V.
and as diagram data must be bidirectional and simplified with only one transistor for power output, so this transistor complicate the communication.
best regards.
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