Main Site Documentation

No slow SPI clock rates with Raptor?


#1

I have been testing SPI with the FEZ Raptor, but cannot achieve slow (<500kHz) clock rates. Here is my code, with the timings I see on my logic analyzer and/or scope.

  Private Function BuildConfiguration(chipselectbarpin As Pin, spiModule As SPI.SPI_module) As SPI.Configuration
        Dim _csht As UInteger = 1  ' _chipselect holdtime mS (time that CD must remain active before unselecting, or time after the read write completion)
        Dim _csas As Boolean = False ' Chip select active state
        Dim _csst As UInteger = 0 ' Chip select Setup Time mS (time acter cs before reading)
        Dim _ce As Boolean = True  ' If true, data is sampled on the rising edge, else falling edge
        Dim _cis As Boolean = True  ' click idle state, high if true
        Dim _cr As UInteger = 5000   ' supposedly clock frequency in kHz
        '   _cr = 1 gives 615KHz
        '   _cr = 2 gives 1.26MHz
        '   _cr = 4 gives 2.5MHz
        '   _cr = 10 gives 6.35MHz
        '   _cr = 20 gives 13.3MHz
        '   _cr = 100 gives 2.51MHz
        '   _cr = 500 gives 13.3MHz
        '   _cr = 1000 gives 1.003MHz
        '   _cr = 2000 gives 2.03MHz
        '   _cr = 5000 gives 5.13MHz

        Dim _spi_mod As Microsoft.SPOT.Hardware.SPI.SPI_module
        _spi_mod = spiModule
        Return New SPI.Configuration(chipselectbarpin, _csas, _csst, _csht, _cis, _ce, _cr, _spi_mod)
    End Function


#2

@ rockybooth -

We will check on Raptor, but I also saw that bug on another device.
Thank for mentioning me to remember this bug.


#3

@ rockybooth -

It seems we can not do anything with this, because there is 8 bit value to scale from MCK (133MHz), so minium will be 133MHz/255 ~ 500KH. Try to implement SoftwareSPI if you want it really slow.


#4

Thanks for checking. I like the fast rates of the Raptor!
The only reason is why the slow rates are appealing is in debugging as it is easier to see on the scope and logic analyzer.
The docs should probably be changed as the rate is not in kHz unless a minimum value is specified. I suspect that the minimum (and maximum) might be different on other uPs.