how to use UART0_TX and UART0_RX of GPIO as UART on olinuxino A20 lime ?

Started by viko_cano, January 22, 2015, 10:04:11 PM

Previous topic - Next topic

viko_cano

Hi,
I have 3 days trying to use GPIO pins(UART0-RX PIN 26 and UART0-TX PIN 28) as a TTyS1 with a Panasonic Mesh network, i read that Panasonic Module use TTL, i have a C sample code tested on Linux debian, also on this olinuxino but using USB but I want to put 3 Panasonic module using this GPIO then open the port with C like TTyS1 TTyS2 something like this.

I add my picture showing how I connect my Panasonic module




jmyreen

If the module has a TTL interface, then you can't connect it directly to the A20. TTL signals are 5 V, and the maximum voltage you can put on an A20 input pin is 3,6 volts.

viko_cano

Right now olinuxino A20 is powered at 5V so practically TTL and CMOS are compatible. if isn't  possible jmyreen, do you know how can I connect three Modules at the GPIO?

JohnS

The A20 CPU is powered at 3V3 not 5V and cannot handle 5V!  You'll damage it.  As posted, it is not TTL compatible.

UART signals may need inverting.

John

viko_cano

Quote from: JohnS on January 22, 2015, 11:58:27 PM
The A20 CPU is powered at 3V3 not 5V and cannot handle 5V!  You'll damage it.  As posted, it is not TTL compatible.

UART signals may need inverting.

John

I'm using A20-OLinuXIno-LIME2-4GB
https://www.olimex.com/Products/OLinuXino/A20/A20-OLinuXino-LIME-4GB/open-source-hardware

I see at the spec that A20 need 5V input power supply (https://www.olimex.com/wiki/A20-OLinuXino-LIME2#Power_supply_and_consumption)

do you know a solution?, im thinking to buy a MAX232.

JohnS

The BOARD may need 5V - use whatever its spec says -  but the CPU does not and it cannot handle 5V at any pin.  The A20 pins are NOT protected against bad voltages such as 5V.

Use any level convertor etc as appropriate.

John

Gerrit


jmyreen

Using a MAX232 (or related product like the MAX3232) is not the solution if the module interface is TTL. The MAX232 is intended to interface to RS-232, which uses voltages between -15..+15V.

To connect a TTL output to a 3.3V input pin, you could use a circuit like 74HC244 (not 74HCT244) with a +3.3V supply voltage (Vcc). This circuit includes a clamping diode, which makes it possible to use input voltages greater than 3.3V (5V in this case), but you have to put a current limiting resistor in series with the with the input.

To interface the other way (output from A20 to TTL) is at least in theory possible with a direct connection, since TTL defines a voltage > 2V as logical "1". If you wish, you can use a buffer like 74HCT244 (note: HCT this time) with a +5V supply voltage (Vcc).

http://www.nxp.com/documents/data_sheet/74HC_HCT244.pdf

Gerrit

Quote from: jmyreen on January 23, 2015, 09:52:26 AM
Using a MAX232 (or related product like the MAX3232) is not the solution if the module interface is TTL. The MAX232 is intended to interface to RS-232, which uses voltages between -15..+15V.

That depend, if you use 2 you can connect at RS-232 level, with all the advances that go with it like longer cables between the 2 interfaces. and more flexible to connect to other devices.

viko_cano

Quote from: jmyreen on January 23, 2015, 09:52:26 AM
Using a MAX232 (or related product like the MAX3232) is not the solution if the module interface is TTL. The MAX232 is intended to interface to RS-232, which uses voltages between -15..+15V.

To connect a TTL output to a 3.3V input pin, you could use a circuit like 74HC244 (not 74HCT244) with a +3.3V supply voltage (Vcc). This circuit includes a clamping diode, which makes it possible to use input voltages greater than 3.3V (5V in this case), but you have to put a current limiting resistor in series with the with the input.

To interface the other way (output from A20 to TTL) is at least in theory possible with a direct connection, since TTL defines a voltage > 2V as logical "1". If you wish, you can use a buffer like 74HCT244 (note: HCT this time) with a +5V supply voltage (Vcc).

http://www.nxp.com/documents/data_sheet/74HC_HCT244.pdf

taking the theory about that it's possible connect directly my Module, I set my script.bin:
[uart_para0]
uart_used = 1
uart_port = 1
uart_type = 2
uart_tx = port:PB22<2><1><default><default>
uart_rx = port:PB23<2><1><default><default>

[uart_para1]
uart_used = 1
uart_port = 1
uart_type = 8
uart_tx = port:PA10<4><1><default><default>
uart_rx = port:PA11<4><1><default><default>
uart_rts = port:PA12<4><1><default><default>
uart_cts = port:PA13<4><1><default><default>
uart_dtr = port:PA14<4><1><default><default>
uart_dsr = port:PA15<4><1><default><default>
uart_dcd = port:PA16<4><1><default><default>
uart_ring = port:PA17<4><1><default><default>
[uart_para2]
uart_used = 1
uart_port = 2
uart_type = 4
uart_tx = port:PI18<3><1><default><default>
uart_rx = port:PI19<3><1><default><default>
uart_rts = port:PI16<3><1><default><default>
uart_cts = port:PI17<3><1><default><default>

[uart_para3]
uart_used = 1
uart_port = 3
uart_type = 4
uart_tx = port:PH00<4><1><default><default>
uart_rx = port:PH01<4><1><default><default>
uart_rts = port:PH02<4><1><default><default>
uart_cts = port:PH03<4><1><default><default>

[uart_para4]
uart_used = 1
uart_port = 4
uart_type = 2
uart_tx = port:PG10<4><1><default><default>
uart_rx = port:PG11<4><1><default><default>

after I rebuild the script.bin,I modified the PINOUT for using TTyS4 (also i added a led),I rebooted olinuxino

at this moment if I send this command led turn on
root@a20-olimex:~# echo "123456789" > /dev/ttyS4

when I see what happen on serial ports i saw this
root@a20-olimex:~#cat /proc/tty/driver/serial

0: uart:U6_16550A mmio:0x01C28000 irq:33 tx:14090 rx:247 RTS|DTR
1: uart:U6_16550A mmio:0x01C28400 irq:34 tx:0 rx:0 CTS|DSR|CD|RI
2: uart:U6_16550A mmio:0x01C28800 irq:35 tx:0 rx:0 CTS
3: uart:U6_16550A mmio:0x01C28C00 irq:36 tx:0 rx:0 CTS
4: uart:U6_16550A mmio:0x01C29000 irq:49 tx:305 rx:0 <---data count
5: uart:U6_16550A mmio:0x01C29400 irq:50 tx:0 rx:0
6: uart:U6_16550A mmio:0x01C29800 irq:51 tx:0 rx:0
7: uart:U6_16550A mmio:0x01C29C00 irq:52 tx:0 rx:0

but when I try to use with C program, nothing is happening

today I will get 74HCT244 but if I could use directly, it could be perfect.

jmyreen

It's hard to tell how your C program differs from the echo command. If you are using buffered I/O (fwrite, fprintf, etc.), it could be as simple as a missing fflush call.

Regarding the voltages: the A20 data sheet says that a high input voltage (Vih) on an I/O pin should typically be 3.3V, min. 2.7V and max. 3.6V.