PX4 / DriverFramework

Operating system and flight stack agnostic driver framework for POSIX (Linux, NuttX, Mac OS, QNX, VxWorks).
82 stars 132 forks source link

Change SPI frequency setting #189

Closed crossa closed 7 years ago

crossa commented 7 years ago

Change freq setting of spi support raspberry pi. The frequency of spi should be set to 1/4 of max frequency of the MCU. Other wise it will cause FIFO occupation and FIFO overflow

julianoes commented 7 years ago

@crossa What is the reason behind BITS_DLPF_CFG_184HZ instead of BITS_DLPF_CFG_250HZ. I'm just curious what you found out.

crossa commented 7 years ago

@julianoes I have tested it. If using BITS_DLPF_CFG_250HZ , it can cause FIFO occupation and FIFO overflow on RPI3 or other low performance board.

Using BITS_DLPF_CFG_184HZ instead of BITS_DLPF_CFG_250HZ and 5Mhz speed instead of 20M is the most conservative way to make it correctly。

julianoes commented 7 years ago

@crossa Ah I checked the register map and descriptions (page 13) and I realized that setting the DLPF to 184 Hz reduces the rate from 8kHz to 1kHz. This makes perfect sense now.

crossa commented 7 years ago

@julianoes Yes,you got it. When I fixed spi frequency ,I found after the compass initialization,the data of compass will be fault after a few minute. I am very curious why compass data will be wrong and "fifo occupation" still appear in the pxh terminal. Then I read the code ,I find when using EDISON board, the DLPF value was be set to 184HZ ,so I try 184HZ. All the troubles has gone away.

julianoes commented 7 years ago

@crossa ok that's helpful. We might even want to do the same for Snapdragon.