I’m new at programming the BBB and to Linux in general, so I’m trying to figure out what’s happening when I’m setting up a SPI-connection.
I have set up a SPI-connection, using a Device Tree Overlay, and I’m now running spidev_test.c to test the connection. For the application I’m making, I need a quite specific frequency. So when I run spidev_test and measure the frequency of the bits shiftet out, I don’t get the expected frequency.
I’m sending a SPI-packet containing 0xAA, and in spidev_test I’ve modified the “spi_ioc_transfer.speed_hz” to 4000000 (4MHz). But I’m measuring a data transfer frequency of 2,98MHz. I’m seeing the same result with other speeds as well, deviations are usually around 25-33%.
How come the measured speed doesn’t match the assigned speed?
How is the speed assigned in “speed_hz” defined?
How precise should I expect the frequency to be?