2023-09-30 11:35 PM
Hello!
We are using STHS34PF80 IR sensor and STM32L031F6 processor in our IR motion sensor device.
In STHS34PF80 datasheet is said that SPI clock speed could be up to 10 MHz.
But we can achieve clock speeds up to 250 kHz.
Strange think is that we are able to read WHO_AM_I byte at 8 MBit/s, but InfraRedPD library doesn't work.
It works at speeds up to 250 kBit/s.
Here is our read function:
Would you please advice!
2023-10-01 12:53 AM
1. how you set cpha+cpol ? i think, your IR chip wants: cpol hi + cpha 2 edge
2. basically you can read 4 values in about 0,5ms at 250k speed;
IR update rate is 1...10Hz typ. , so 100...1000ms between accesses.
so need 0,5% cpu time at 250k rate -- what you want to gain here ?
2023-10-01 03:28 AM
Hi!
Thank you for your reply.
It doesn't work with cpol hi + cpha 2 edge @8 Mbit/s?!
2023-10-01 10:43 AM
The SPI can run just fine at 8 MHz, as you've seen by reading the WHO_AM_I register. Something else is happening here.
> InfraRedPD library doesn't work.
What isn't working about it? As @AScha.3 suggests, it could very well be that you are trying or expecting to read too often and the CPU can't keep up.
The code you presented doesn't appear to have any issues.
2023-10-01 10:54 AM
Hi!
We are setting ODR to 4Hz and I think this is not a problem for the processor to read necessary bytes.
But when I set SPI speed to 8 Mbit/s or any speed above 250kBit/s InfraRedPD library stops detecting movements?!
Also I am printing data_out.t_obj_change and it varies too small to exceed the movement threshold.
Library begins to work again when I set SPI speed to 250 kBit/s or less.