veryevil
Posts: 30
Joined: Fri Mar 09, 2012 3:38 pm

SPIDev Frequency halves?

Sat Feb 21, 2015 1:05 pm

Hi, just started using my PI2 and trying to get SPI working.

I'm using a slightly modified version of the code listed under the heading "Using The SPI Port Without the BCM2835 Library" http://www.raspberry-projects.com/pi/pr ... -interface

Its working great after I added a memclr to the SpiWriteAndRead function, took the loop out and made it send whole packets instead of bytes.

The problem is the clock frequency seems to half randomly so I have it set for 1Mhz but sometimes it will be 500khz

I'm using a clock value of 500000 for spi_speed

Code: Select all

ioctl(*spi_cs_fd, SPI_IOC_WR_MAX_SPEED_HZ, &spi_speed); 
ioctl(*spi_cs_fd, SPI_IOC_RD_MAX_SPEED_HZ, &spi_speed);

... and later ...

spi.speed_hz = (spi_speed);
my main just sends a 6 byte packet in a loop 100 times with a second delay between each. Most are at 1Mhz but some are at 500Khz.

Any thoughts?

Return to “Interfacing (DSI, CSI, I2C, etc.)”