Skip to main content
Visitor II
September 18, 2021
Question

Question about IIS3DWB INTERNAL_FREQ_FINE register

  • September 18, 2021
  • 2 replies
  • 870 views

Hello, I’m using the IIS3DWB with an Arduino Portenta, using a procedure similar to Kris Winer’s github (i.e. using the FIFO buffer in continuous mode, 256 watermark, stop on watermark, data ready interrupt on watermark, running various cycles until having all the required samples for FFT).

Reading FREQ_FINE from the INTERNAL_FREQ_FINE register doesn’t seems to work. It gives 0 when I read those bits (I tried reading from the register in different parts of the code).

Can you give me an advice on how to make it work? I made sure to have 1 in the variable that receives the value from FREQ_FINE[7:0] bits, in order to see if the 0 was really the read from INTERNAL_FREQ_FINE register.

I wanted to check the sampling frequency since in my experiments it seems to be slightly different to 26667 Hz. And I came to the problem of not being able to have information from INTERNAL_FREQ_FINE register

Many thanks in advance!

    This topic has been closed for replies.

    2 replies

    ST Employee
    September 28, 2021

    Hi @FCook.1​ ,

    let me ask you some question to better understand the situation:

    how are you reading the register?

    is the read of the INTERNAL_FREQ_FINE register the same as other read performed in the code?

    Niccolò

    FCook.1Author
    Visitor II
    September 29, 2021

    Hi Niccolò, I'm reading as follows:

    #define IIS3DWB_INTERNAL_FREQ_FINE    0x63

    ....

    uint8_t IIS3DWB::readByte(uint8_t reg) 

    {

     SPI.beginTransaction(SPISettings(IIS3DWB_SPI_CLOCK, MSBFIRST, IIS3DWB_SPI_MODE));

     digitalWrite(_cs, LOW); 

     SPI.transfer((reg & 0x7F) | 0x80);

      

     uint8_t temp = SPI.transfer(0);

      

     digitalWrite(_cs, HIGH);

     SPI.endTransaction();

     return temp;

    }

    ....

    uint8_t IIS3DWB::getFreq()

    {

     uint8_t temp = readByte(IIS3DWB_INTERNAL_FREQ_FINE); // read freq register

     return temp;

    }

    Other parts of the code use readBytes, so that part of the code is OK. I've tried using the getFreq function in different parts of the code and the answer is 0.

    PS: I've stoped using the FIFO and now using the sensor only in bypass mode, it seems to me simpler to implement. With the FIFO I had missing values when looping after the buffer is full.

    Regards,