09-21-2022 10:59 AM
I want to use the BMA456 for anymotion detection. I'm using the config file from the bma456_an.c of the SensorApi on GitHub.
But I don't get any interrupts (neither at the INT1-pin nor in the INT_STATUS Reg). Here is what I do:
bma456WriteReg(0x7C, 0x02);
busy_wait(TBW_1us(450));//wait for 450us
bma456WriteReg(0x59, 0x00); //Adr. 0x59: INIT_CTRL
//write Configfile
(void)i2cWrite(BMA456_SLAVEADR_WRITE, (uint8*)bma456an_config_file, sizeof(bma456an_config_file));
bma456WriteReg(0x59, 0x01); //Adr. 0x59: INIT_CTRL
busy_wait(TBW_1ms(140));//wait for 140ms
bma456WriteReg(0x41, 0x00);//Adr. 0x41: range
bma456WriteReg(0x53, 0x0a);//Adr. 0x53: INT1_IO_CTRL
bma456WriteReg(0x55, 0x01);//Adr. 0x55: INT_LATCH
bma456WriteReg(0x56, 0x10);//Adr. 0x56: INT1_MAP
bma456WriteReg(0x28, 0x38);//Adr. 0x28: FEAT_EN_1
bma456WriteReg(0x7D, 0x04);//Adr. 0x7D: acc_en
//read reg 0x2A, bit4 == 1? init_ok
adr = 0x2A;
(void)i2cWriteRead(BMA456_SLAVEADR, &adr, 1, buf, 1);
printf("bma456 init: 0x%x", buf[0] & 0x1F);
//read anymotion config
adr = 0x5E;
(void)i2cWriteRead(BMA456_SLAVEADR, &adr, 1, buf, 4);
printf("bma456 config: 0x%x, 0x%x, 0x%x, 0x%x", buf[0], buf[1], buf[2], buf[3]);
//write anymotion config
buf[0] = 0x5E;
buf[1] = 0x0A;
buf[2] = 0x00;
buf[3] = 0x05;
buf[4] = 0xE0;//axes enable
(void)i2cWrite(BMA456_SLAVEADR, buf, 5);
reading Register INTERNAT_STATUS returns 0x01 (ASIC initialized)
Reading the anymotion config returns 0xc8, 0x2e, 0x00, 0x2e. This should be default values 0xcc, 0x00, 0x05, 0x00 according to Application note "Hearables feature set"
any ideas?
Solved! Go to Solution.
09-28-2022 10:13 AM
Both work for me. As described in Application note AN feature set I do:
- for any motion: in reg 0x56, enable 0x20; set reg 0x5b to 0x00; set parameters (4 bytes) in reg 0x5e; monitor reg 0x1c for 0x20
- for no motion: in reg 0x56, enable 0x40; set reg 0x5b to 0x02; set parameters (4 bytes) in reg 0x5e; monitor reg 0x1c for 0x40
09-28-2022 11:17 AM - edited 09-28-2022 11:31 AM
Ah, now I got it:
I took reg 0x56 from the Application Note "Hearables feature set": Bit4 = any_motion_out, Bit5 = no_motion_out
I should have taken it from the Application Note "AN feature set" (which I didn't know until now): Bit5 = any_motion_out, Bit6 = no_motion_out
But what is that with reg 0x5B? Is that undocumented?
09-28-2022 12:07 PM
Yes, as far as I know the two registers 0x5c and 0x5b are undocumented, but they're used in the stream_transfer_write function to write chunk by chunk and in a bunch of other functions to read and write feature settings. I find it more convenient to use these rather than read the entire content of 0x5e to modify only a few bits. I came to wonder why they decided to privilege the latter option.