How do I change the output data rate for the Qwiic KX132 in conjunction with the Redboard?

I am unable to alter the output data rate for the KX132 from 50Hz to another value.

In particular I wish to maximize the rate by changing the ODCNTL value to 15.

Any suggestions as to how to do this starting with the Arduino KX132 example code would be appreciated.

I am attempting to become more competent in C++ programming, but as I’ve not had a reason to code in C or it’s variants for decades, it’s coming along quite slowly, despite the tutorials I’ve been taking.

https://github.com/sparkfun/SparkFun_KX … _KX13X.cpp It’s about 1/4th the way down, 2 paragraphs that hold the code for the sample rate and output data rate…you’d alter the code to suit your use-case from there :slight_smile:

Hope this helps!

Thanks! I had seen the code fragments in the .cpp file but my unfamiliarity with C++ is a problem as I’m unsure how to use them.

I see the word “rate” in various lines. “rate” doesn’t seem to be declared in the .h file or in the .cpp file and the concept of classes is pretty fuzzy to me at the moment.

Do I just replace “rate” with the desired value in the associated register i.e. 0x0F for 1111? However if I do the check for it being within the 0-15 range would not seem to work. So is rate actually a variable, and if so is it declared somewhere with a value assigned to it? Certainly the code compiles and functions correctly so the problem is clearly with my lack of understanding.

My apologies for the basic questions. `

They’re ‘functions’ - though we in Technical Support aren’t coders either :frowning:

The best direction I can offer is to have you run through the hookup guide https://learn.sparkfun.com/tutorials/tr … guide-/all, paying special attention to the 'Device Setup & Configuration" section, and reference the Tech Manual and Datasheet that the hookup guide has linked - not ideal, but with enough effort all the parts are there to accomplish what you’d like (one thing it mentions is that you’ll need to use SPI for the MAX data rate, so please note that portion as well!)

In the meantime hopefully someone in the forums that has experience with this will chime in with the code they used :wink:

Thank you!

I actually did read the “device setup and configuration” and tried to use the same kind of approach as was seemingly used for the g range setting, but the code won’t compile and doesn’t provide me with an error message that I can use.

Alas, no Good Samaritan has offered to share a suitable code fragment to help out.

I’ll keep on trying.