Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Teensy 3.6 MOSI/MISO pin names wrong, should be SDO and SDI (IMHO)

  1. #1

    Teensy 3.6 MOSI/MISO pin names wrong, should be SDO and SDI (IMHO)

    Greetings!

    I've been learning about SPI in slave mode for the Teensy 3.6. I've been making some progress with Tonton81's libraries (TSPISlave and SPI_MSTransfer) and there's some discussion about this issue here https://forum.pjrc.com/threads/50008...l=1#post234115

    Anyway, this resulted in me digging into the MK66 reference manual enough to convince myself that the particular MK66 pins broken out to the Teensy 3.6 SPI data pins (Teensy pins 0,1,11,12,44,45,51,52) can not be reconfigured by the Port Control Block to operate in the appropriate data flow direction for SPI Slave mode if these pin names were to make sense.

    E.g. Teensy3.6 pin 0 is MOSI0, "Master Out Slave In" so this pin would be for data to flow into the port in slave mode. But, that can't be configured, so this pin is really Master Out Slave Out. "MOSO" would be confusing and ugly, but SDO "Serial Data Out" does make sense.

    Please correct me if I'm wrong! The places to look in the reference manual are the table in section 11.3.1 and figure 57-1 is helpful too.

    Cheers,
    Doug

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,651
    Yes there are multiple ways to name these pins, which can be confusing.

    But a lot of things here are setup to make it easy for people to go from one Arduino processor to another. So for example if you look at the Arduino
    documentation for SPI https://www.arduino.cc/en/reference/SPI
    You will see they talk about MOSI and MISO.

    If you look at Wikipedia for SPI: https://en.wikipedia.org/wiki/Serial...eral_Interface you will see they mention MOSI and MISO
    In there their discussion of pins also discuss SDI and SDO as well as MOSI/MISO...

    And different chips and manufactures don't call it SPI but call it TWI (Two Wire Interface)...

  3. #3
    Yes, but a pin that is SDO in *both* master and slave mode is neither MOSI nor MISO. These are not just different, synonymous, names for the same thing.

    I also understand that most people use the Arduino/Teensy as the master, so this isn't often problem. Mostly people pay attention to the "Master Out" and "Master In" part of the name, and don't think about slave mode.

    Do you understand my point about the direction of data flow in slave mode? Pin 0 cannot have data go "In" so "Slave In" is wrong, which is very confusing for people who are familiar with SPI.

    Cheers,
    Doug

  4. #4
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    513
    I get what you are going for but the Slave part of MOSI and MISO does not in fact refer to using a device in slave mode, rather it refers to where the wire would be hooked to for a Slave device if the Teensy is operating in Master mode. For example, you would run a wire from the Teensy Master Out port to a Slave devices In port and vise versa for Master In Slave Out.

  5. #5
    Quote Originally Posted by vjmuzik View Post
    I get what you are going for but the Slave part of MOSI and MISO does not in fact refer to using a device in slave mode, rather it refers to where the wire would be hooked to for a Slave device if the Teensy is operating in Master mode. For example, you would run a wire from the Teensy Master Out port to a Slave devices In port and vise versa for Master In Slave Out.
    What you say is fine, if the Teensy is being used in Master mode and, like I said, in the Arduino/Teensy world the Arduino/Teensy is usually the master.

    But if the Teensy is being used in Slave mode then data should flow in to the MOSI pin, at least based on how the rest of the SPI world works. There are devices that can operate in either Master or Slave mode. For example, the AVR32105 SPI driver can be used in Master or Slave mode, and the table on page three of its datasheet shows this nicely (attached here).

    If a device has a pin called "SDO" we can reasonably be expected to have SPI data flow out of in all modes which is exactly what "MOSI" does on T3.6.

    I'm not just being argumentative! I think this is worse that confusing, and is actually wrong in Slave mode.

    Attachment 19516

  6. #6
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,651
    I can agree or disagree...

    But in many cases like this, it is what it is... That is even if one could come up with a good argument on changing things like this. They have been this way for many years across many different processors and documents and ... So my guess is it would be very unlikely it will change.

    Of course you can always either help with adding additional stuff to the Wiki website that @luni and others have started to explain some of this.

    The difficulty with many things like this, is how complete of information can you give on a little card or the like that is helpful and does not confuse the majority of people.

    Example should the serial ports TX pin be relabeled as if you change the serial port to half duplex mode it can also be RX?

    Again I appreciate the information you are presenting, I am just personally not sure what would be realistically changed. But then again maybe the owners of PJRC may differ.

    Again I personally hear you and sometimes I have to figure out what different SPI devices mean, when some say MOSI and MISO others say SDI/SDO and others may say something generic like RX and TX. And then again with RX and TX labels does RX imply it connects to RX pin or that it does RX and connects to TX pin?...

  7. #7
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    156
    And, I'd miss MOSI & MISO. I always see them as these two Asian helpers..

    Weird I know.

    -jim lee

  8. #8
    @KurtE
    No doubt there's a lot of confusion, and I certainly get confused. But, my point is that there *are* devices that implement MISO and MOSI, but this isn't one of them... MISO and MOSI are perfectly respectable names with zero ambiguity. It only gets ambiguous if we become accustomed to doing perverse things like connect "MISO" to "MOSI" to get something to work... (That is the only way to get two Teensy3.6 to talk to each other over SPI and is, frankly, broken...)

    Similarly TX connects to RX and RX connects to TX in sane implementations (but I've also had to do otherwise in broken implementations, again no argument there, and I'm ok with TX/RX when appropriate). There is an actual RS232 standard to define TX and RX, which should help, but doesn't always...

    I think the PJRC reference cards are masterful, and I have them in my office, lab, home office, home lab etc etc and there certainly is a limit to what can go on them. I'm not advocating for asterisks and explanations or the card, but my point is that these names are actually wrong. It is only not an obvious problem because these devices are generally Masters.

    Understand, I'm a huge fan of PJRC and the Teensy family. I have bought and used dozens of the T3.6 and sold a significant amount of T3.6 based lab hardware devices to serious people who expect it to work well. I hope my explanation above will help someone and I'm happy to add it to the Wiki in due course.

    @Jim, Sadly. I've already fired my helpers MISO and MOSI. I need to expose this interface to a customer, and our box will be operating as a Slave. I'm documenting this pin as SDI, because he sends his Serial Data In to the slave on that pin.

    Best,
    Doug

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •