Main Site Documentation

SPI2 on FEZ non Wifi board


#1

2 questions about spi on the FEZ board and TinyCLR.
Some of this stuff is new to me so my questions border at the noob level.

  1. Regarding SPI1, im a bit confused about the ChipSelectType and ChipSelectLine in the SpiConnectionSettings class.
  • What is the purpose of ChipSelectType = Controller, I do not see a CS pin for SPI1 like SPI2 has, and im assuming ‘Controller’ value could only be used for SPI2 to differentiate between using a GPIO as CS or its own CS pin.

But as i mention if SPI1 doesn’t have a CS so then would only GPIO be valid for SPI1?

Or do i misunderstand something fundamental about the 2 SPI buses on the device?

  • And what about a value of NONE, how is that used? i thought a CS is always required for SPI.
  1. Looking over the schematic of my non wifi FEZ, would i be correct to assume i could utilize the header H1 and/or the wifi pads on the FEZ and utilize SPI2? I mean the SpiBus class has values for both "Spi1 and WiFi, but not sure if there is another limiting factor.

Please advise.


#2

:wink:
CS is not part of the SPI bus - it is an arbitrary GPIO pin that you connect to the CS line of the device in question. The whole idea of the bus is you have many SPI devices all connected to the SPI lines, each with their own CS line - so when that GPIO is set (or that device’s configuration becomes active), it is the only device that listens to commands on the bus.

CS is able to be hard-wired (and therefore you would use the setting NONE), but then the SPI is no longer a bus but is dedicated to that device only.

Without looking at the schematic myself, it is possible (and perhaps even sensible) for the WiFi to be dedicated on one SPI channel, so that your code can’t affect the wifi communication that TinyCLR OS needs to do…


#3

So the CS pin on the controller is something else entirely…
And using value ChipSelectType = NONE will dedicate that bus to that device…
I am guestimating the ChipSelectType = GPIO value would allow you to select the Chip Select line with ChipSelectLine property.

So one thing i still missing, what does ChipSelectType = Controller signify?


#4

Some chips have built in hardware control over a specific CS pin. This is not a GPIO, but a special CS SPI pin. None of the hardware we use today has this. This leaves you with GPIO, which you can control yourself or let TinyCLR do it for you.


#5

I see. so even though SPI2.CS is on the controller, it is not currently used by TINYCLR, as well currently the “Controller” value of SpiChipSelectType enum is currently unused…

So to the second question of my original post:

“Looking over the schematic of my non wifi FEZ, would i be correct to assume i could utilize the header H1 and/or the wifi pads on the FEZ and utilize SPI2?”

I should indeed be able to utilize SPI2 via hader H1 and/or the unused wifi pads, setting it up using whatever GPIO as its CS and the WiFi value in the SpiBus class:

var settings = new SpiConnectionSettings
		{
			ChipSelectType = SpiChipSelectType.Gpio,
			ChipSelectLine = FEZ.GpioPin.D2,
		};

var spiController = SpiController.FromName(FEZ.SpiBus.WiFi);
_spiBus = spiController.GetDevice(settings);

#6

I do not think the SPI WiFi pins are exposed, but why would you need them? Isn’t it easier to use the SPI available on the headers? D11 D12 D13 http://docs.ghielectronics.com/hardware/fez/intro.html (see the image with the pinout)


#7

I do not think the SPI WiFi pins are exposed

I dont have the wifi FEZ so measuring continuity the pads are exposed where the wifi module would have been. Also MISO and MOSI are on H1.

but why would you need them?
Isn’t it easier to use the SPI available on the headers? D11 D12 D13

Well if PB4 or PB5 of PWM8 is needed otherwise, then SPI1 wouldn’t be available to begin with and thus not easier.

That said, i now see the specification lists the FEZ with only 1 SPI available so there’s that…
Surely the wifi uses the spi on the wifi version no? So i was thinking it was perhaps available.
Just trying to understand the board, but from the language, spec, board version, spi is a bit contradictory,

Thanks for the info.


#8

SPI 2 is available on the WiFi pads. That is what we use to talk to WiFi.