[Teensy4, 4.1, Teensy MicroMod] - Pins, Uarts, ...

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
KurtE
Posts: 11
Joined: Mon Mar 28, 2022 1:52 pm

[Teensy4, 4.1, Teensy MicroMod] - Pins, Uarts, ...

Post by KurtE » Sat Apr 23, 2022 4:10 pm

Sorry, not sure if best to ask this as part of other threads and/or different topics...

But I am trying to understand what things are defined or not defined and if they should be.

For example Teensy 4.0, the pins.csv file only go up to: D33,GPIO_EMC_07
Where as if you look at the T4.0 card from PJRC you will see that they are defined up through D39

Yes you do have those pins sort of defined under:

Code: Select all

CMD,GPIO_SD_B0_00
CLK,GPIO_SD_B0_01
DAT0,GPIO_SD_B0_02
DAT1,GPIO_SD_B0_03
DAT2,GPIO_SD_B0_04
DAT3,GPIO_SD_B0_05
Which are the logical names for the signals if you are using it for SDIO support. My guess on the T4 (and even more the MicroMod), that the users will use these extra pins more often for IO pins than for SDIO On T4.1 these are pins (42-27) and in this case more likely to be use for SDIO... But they are defined in that pins.csv file.

On Micromod - again more likely as extra signals as for very few if any of the Sparkfun breakout boards setup an SDIO card connection. Mine does, but...

So I am assuming OK to add for T4?

Side question to self (and others): if many of the setups for T4 and TMM may wish to use SD through SPI, I don't think any module is included that supports this... (Yes you can download)... Curious on other board types without SD if the .py version is included by default?

UARTS: Support for alternate pins. I am not sure if there is any way to say I wish to use different RX, TX pins for the Teensy UART objects?
There are not too many normal ones, but for example T4.1 could use 52 for RX1 and 53 for TX1. I think I saw on documentation page maybe way to specify on the init method(tx=, rx=)... But my impression looking through the code, that there may not be any support in there for this.... Could be wrong.

And I am also probably including the possibility of using any XBAR pin for the RX pin, which is an option, I added that code into the Arduino code base. And ditto for CTS. Although you can only do either RX or CTS on any UART (i.e. register setting for which one...)

Also curious to see if any support for Half duplex.
Likewise support for RS485, or more particular like the Arduino code base, the ability to set the Transmitter enable pin?

I.e. thinking of trying some quick and dirty test to see if I can drive a Dynamixel servo, and my breakout board is setup for using a Serial port and a pin to specify if you are now doing TX or RX...

Now back to playing

KurtE
Posts: 11
Joined: Mon Mar 28, 2022 1:52 pm

Re: [Teensy4, 4.1, Teensy MicroMod] - Pins, Uarts, ...

Post by KurtE » Sun Apr 24, 2022 12:39 am

Some notes after playing a little bit.

So far I don't think the Teensy boards port, That the UARTS code has support to set which pins to use for TX or RX, have not tried the other two...

Code: Select all

>>> import machine, sys, os
>>> uart1 = machine.UART(1)
>>> uart1.init(tx=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: extra keyword arguments given
>>> help(uart1)
object UART(1, baudrate=115200, bits=8, parity=None, stop=1, rxbuf=256, txbuf=256, timeout=1, timeout_char=           1, invert=None) is of type UART
  init -- <function>
  any -- <function>
  read -- <function>
  readline -- <function>
  readinto -- <function>
  write -- <function>
  sendbreak -- <function>
  INV_TX -- 1
  INV_RX -- 2
>>> uart1.init(baudrate=1000000)
UART(1, baudrate=1000000, bits=8, parity=None, stop=1, rxbuf=256, txbuf=256, timeout=1, timeout_char=1, invert=None)
>>>

Halfduplex - Do not see any support.

RS485/Dynamixel - Support I do see another thread on this for the PyBoard and maybe stm... With library that supports it
https://github.com/dhylands/bioloid3/bl ... rt_port.py

Looks like it is new class the contains a UART class object... And uses inline assembly...

Could probably do something similar for mimxrt... But I am not great at assembly ....

Question is does it make sense to add some support directly in the UART object?

For example on my current Teensy Micromod break out, I have it setup with with two buffers, one has enable the other has not enable, so use a direction pin to direct RX or TX to the TTL Dynamixel signal.

With Teensy Arduino code, I can simply tell the UART to use this pin and it automatically sets to TX mode, when the SerialX.write() calls are made it keeps it asserted until the TX queue is emplty and the last bits are transferred. At which point the IRQ handler that sees this state then sets that pin to RX mode...

Also have support built in as well for half duplex where the TX pin works as either TX or RX depending on the state of a register and same code to set the RS485 line can also instead set the register to be in RX mode...

But on a more minimalistic approach without this level of support, the library does it brute force. When it wishes to send a packet it
does ligically:
digitalWrite(direction pin, value for TX);
SerialX.write(bytes of the packet);
SerialX.flush();
digitalWrite(direction pin, value for RX)

But this requires the ability to have the code wait again until tx buffer is empty and the transfer complete state...
Not sure if there is way to do this?

Now back to more experimenting.

Post Reply