We're doing a little testing with the SPI 0 controller on the expansion board. The current environment is Windows 10 IoT Core and Visual Studio 2015 with C++/CX for the application development. If we run the following code:
#define SPI_CS_FLASH 0 #define SPI_FQ_FLASH 25000000 ... m_pSpiSettingsFlash = ref new Windows::Devices::Spi::SpiConnectionSettings(SPI_CS_FLASH); m_pSpiSettingsFlash->ClockFrequency = SPI_FQ_FLASH; m_pSpiSettingsFlash->Mode = Windows::Devices::Spi::SpiMode::Mode0; Platform::String ^pDeviceSelector = Windows::Devices::Spi::SpiDevice::GetDeviceSelector(); Windows::Devices::Enumeration::DeviceInformationCollection ^pDeviceInformationCollection = concurrency::create_task(Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(pDeviceSelector)).get(); m_pSpiFlash = concurrency::create_task(Windows::Devices::Spi::SpiDevice::FromIdAsync(pDeviceInformationCollection->GetAt(0)->Id, m_pSpiSettingsFlash)).get(); unsigned __int8 ui8 = 0xAA; unsigned __int16 ui16 = 0xAAAA; unsigned __int32 ui32 = 0xAAAAAAAA; Platform::ArrayReference<unsigned __int8> ui8Array(reinterpret_cast<unsigned __int8 *>(&ui8), sizeof(ui8)); Platform::ArrayReference<unsigned __int8> ui16Array(reinterpret_cast<unsigned __int8 *>(&ui16), sizeof(ui16)); Platform::ArrayReference<unsigned __int8> ui32Array(reinterpret_cast<unsigned __int8 *>(&ui32), sizeof(ui32)); m_pSpiFlash->Write(ui8Array); m_pSpiFlash->Write(ui8Array);
we get extremely slow performance. We're looking for roughly 100 times faster than what we're getting. Is the code wrong, the underlying C++/CX code this slow, the driver this slow, or the hardware not capable?
Here is an image from our scope capturing the results of lines 21 and 22 in the above code:
The amount of time between FS0 going low and the first clock (on each write) is baffling. The amount of time after the last clock (on each write) and FS0 going high is baffling. And finally the amount of time between the two writes is potentially baffling (lots of software layers to go through will certainly contribute to this timing). Can this be sped up?