| View previous topic :: View next topic |
| Author |
Message |
nailuy
Joined: 21 Sep 2010 Posts: 163
|
| strange situation function putc(); |
Posted: Tue Dec 16, 2025 8:07 am |
|
|
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
|
|
Posted: Tue Dec 16, 2025 8:32 am |
|
|
What is on the receiving end of the transmission?
Do you have proper RS-232 level translators" ( MAX232 ? ) |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 20001
|
|
Posted: Tue Dec 16, 2025 8:47 am |
|
|
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
|
|
Posted: Tue Dec 16, 2025 10:37 am |
|
|
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
|
|
Posted: Tue Dec 16, 2025 11:49 am |
|
|
| 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
|
|
Posted: Tue Dec 16, 2025 5:12 pm |
|
|
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
|
|
Posted: Tue Dec 16, 2025 5:54 pm |
|
|
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
|
|
Posted: Tue Dec 16, 2025 7:44 pm |
|
|
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. |
|
 |
|