Current Lua downloadable firmware will be posted here

User avatar
By gerardwr
#4569
zeroday wrote:gpio1 and gpio3 are rx/tx. the default function of these 2pins is uart.
gpio module can use these 2 pins as general io pins, gpio.mode(..)

the issue is, when these pins set as gpio. it works as gpio.
but if you want to set these pins again in uart mode(uart.setup). it failed.

it stays in gpio mode (rx pin). issue 18


Ok, I did not know that redefinition of TX/RX as GPIO line was already possible.
If you do not need the UART, you can use 4 GPIO lines (GPIO0, GPIO1/RX, GPIO2, GPIO/TX).
Correct?

So this would be a good example?
Code: Select all-- define the TX line as general GPIO output line
gpio.mode(4,gpio.OUTPUT)
-- set the TX line to HIGH
gpio.write(4,gpio.HIGH)

-- define the RX line as general GPIO input line
gpio.mode(5,gpio.INPUT)
-- read the level of the RX line
level=gpio.read(5)

-- setup the uart AND set TX and RX to their original uart function, 9600 8N1 ECHO
-- API doc says "echo = 0(close echo back)."
uart.setup( 0, 9600, 8, 0, 1, 1 )
-- or is it?
uart.setup( 0, 9600, 8, 0, 1, 0 )


Correct?
User avatar
By zeroday
#4572
gerardwr wrote:
zeroday wrote:gpio1 and gpio3 are rx/tx. the default function of these 2pins is uart.
gpio module can use these 2 pins as general io pins, gpio.mode(..)

the issue is, when these pins set as gpio. it works as gpio.
but if you want to set these pins again in uart mode(uart.setup). it failed.

it stays in gpio mode (rx pin). issue 18


Ok, I did not know that redefinition of TX/RX as GPIO line was already possible.
If you do not need the UART, you can use 4 GPIO lines (GPIO0, GPIO1/RX, GPIO2, GPIO/TX).
Correct?

So this would be a good example?
Code: Select all-- define the TX line as general GPIO output line
gpio.mode(4,gpio.OUTPUT)
-- set the TX line to HIGH
gpio.write(4,gpio.HIGH)

-- define the RX line as general GPIO input line
gpio.mode(5,gpio.INPUT)
-- read the level of the RX line
level=gpio.read(5)

-- setup the uart AND set TX and RX to their original uart function, 9600 8N1 ECHO
-- API doc says "echo = 0(close echo back)."
uart.setup( 0, 9600, 8, 0, 1, 1 )
-- or is it?
uart.setup( 0, 9600, 8, 0, 1, 0 )


Correct?


Yes that's what I mean.

echo means uart echo char back to serial terminal so when you type you can see what you type.
echo = 0 will disable echo.
but some terminal have a local echo option.
User avatar
By gerardwr
#4577
zeroday wrote:Yes that's what I mean.
..
echo means uart echo char back to serial terminal so when you type you can see what you type.
echo = 0 will disable echo.


Ok, it's clear to me now. Nice feature to have the option of 4 GPIO's, thanks!