当前位置:网站首页>Initialization examples of several modes of mma8452q
Initialization examples of several modes of mma8452q
2022-07-28 12:41:00 【yi_ tianchou】
During this period of time, debug a mma8452Q sensor , Several modes are simply tested , Comments may have inaccurate data , The general flow and registers of each mode operation are no problem , Don't spray ,
Various thresholds , It needs to be changed according to the actual situation .
1、 Sports modevoid MMA8452Q_Init_motion(void)
{
kal_uint8 dev_id;
int i=0;
float temp;
MMA8452Q_Delay(2); // Power on delay
//TODO initialization iic
//MMA8452_Standby();
Single_Write_MMA8452(0x2A,0x10);// Set the device to 100hz odr
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x15,0xf8);// Configure the register by setting “ or ” Conditions OAE =1 Yes XY Direction motion detection and latch
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x17,0x11);// Set the motion detection threshold >3G notes : They count 0.063/ Count 3g/0.063 = 47.6 ~ 48 1.2/0.063 =20
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x18,0x0a);// Set the bucket removal counter 100HZ Sampling rate , timer 100 millisecond To eliminate false degrees
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x2d,0x04);// Enable movement in the system / Free fall interrupt function (CTRL_REG4)
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x2e,0x04);// Will exercise / The free fall interrupt function is configured to INT1 Hardware pin of the (CTRL_REG5)
Single_Write_MMA8452(CTRL_REG1, 0x01);// Set to 800hz
MMA845x_Active();
MMA8452Q_Delay(10);
}
2、 Free fall mode
void MMA8452Q_Init_freefall(void) //mma8452q::mma8452q(uint8_t addr) {
{
kal_uint8 dev_id;
int i=0;
float temp;
MMA8452Q_Delay(2); // Power on delay
//TODO initialization iic
Single_Write_MMA8452(0x2A,0x20);// Set the device to 50hz odr 0x20 , 0x1A =100hz ,0x12= 200hz
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x15,0xB8);// Configure the register by setting “ or ” Conditions OAE =0 Yes XY Direction motion detection and latch
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x17,0x06);// Set the acceleration generated by the motion detection threshold <0.2g notes : They count 0.063/ Count 0.2g/0.063 = 3.17 1.2/0.063 =20
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x18,0x10);// Set the bucket removal counter 50HZ Sampling rate , timer 120 millisecond To eliminate false degrees 10
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x2d,0x04);// Enable movement in the system / Free fall interrupt function (CTRL_REG4)
MMA8452Q_Delay(10);
//Single_Write_MMA8452(0x2e,0x04);// Will exercise / The free fall interrupt function is configured to INT1 Hardware pin of the (CTRL_REG5)
MMA845x_Active();
MMA8452Q_Delay(10);
}
The interrupt registers read by work and free fall are 0x16

3、 Initialize monopulse mode
void MMA8452Q_Init_one_tap()
{
kal_uint8 dev_id;
int i=0;float temp;
MMA8452Q_Delay(2); // Power on delay
//TODO initialization iic
Single_Write_MMA8452(0x2A,0x08);// Set the device to 50hz odr 20 di 1A 100hz 0x12 200hz 0x08 400hz
MMA8452Q_Delay(10);
//2、 Set up run xyz Axis single point interrupt
Single_Write_MMA8452(0x21,0x15);// Set up xyz Direction interruption
MMA8452Q_Delay(10);
//3、 Set single point of interruption The threshold of
Single_Write_MMA8452(0x23,0x19);// Every step is 0.0063g/count 1.575g/0.063 = 25counts 2.65g/0.063g=42counts
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x24,0x19);//1.575g
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x25,0x2A);//2.65g
MMA8452Q_Delay(10);
//4、 Set the trigger time of single point interrupt 50ms Normal mode is not low filtering
//50ms/0.063 = 80counts
Single_Write_MMA8452(0x26,0x50);//50ms
MMA8452Q_Delay(10);
//5、 Set delay time
// The data frequency is 400hz Every step is 1.25ms
//300ms/1.25ms = 240conut
Single_Write_MMA8452(0x27,0xF0);//50ms
MMA8452Q_Delay(10);
//6、 Set the system interrupt to int1
Single_Write_MMA8452(0x2D,0x08);// Set the interrupt area system CTRL_REG4
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x2E,0x08);// Specify the hardware interrupt pin to INT1 CTRL_REG5
MMA8452Q_Delay(10);
//7、 Activate the chip
MY_Multiple_Read_MMA8452(0x2A,0);// The read value is paid BUF[0]
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x2A,BUF[0]|0x01);// Specify the hardware interrupt pin to INT1 CTRL_REG5
MMA8452Q_Delay(10);
}
4、 Initialize dual pulse mode
void MMA8452Q_Init_two_tap()
{
kal_uint8 dev_id;
int i=0;
float temp;
MMA8452Q_Delay(2); // Power on delay
//TODO initialization iic
//1、 The chip enters standby mode Set to 400hz
Single_Write_MMA8452(0x2A,0x08);// Set the device to 50hz odr 20 di 1A 100hz 0x12 200hz 0x08 400hz
MMA8452Q_Delay(10);
//2、 Set up run xyz Axis single point interrupt Double click interrupt DPA =0
Single_Write_MMA8452(0x21,0x2A);// Set up xyz Direction interruption
MMA8452Q_Delay(10);
//3、 Set the interruption of each axis The threshold of Every step is 0.0063g
Single_Write_MMA8452(0x23,0x19);// Every step is 0.0063g/count 1.575g/0.063 = 25counts 2.65g/0.063g=42counts
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x24,0x19);//1.575g
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x25,0x2A);//2.65g
MMA8452Q_Delay(10);
//4、 Set the trigger time of single point interrupt 60ms 400HZ ODR Step yes 1.25ms Every step (count)
//60ms/1.25 = 48counts
Single_Write_MMA8452(0x26,0x30);//60ms
MMA8452Q_Delay(10);
//5、 Set delay time 200ms Low filter mode 400hz ODP LPMODE Step yes 2.5ms
// The data frequency is 400hz Every step is 2.5ms
//200ms/2.5ms = 80conut
Single_Write_MMA8452(0x27,0x50);//200ms
MMA8452Q_Delay(10);
//6、 Set the second pulse interval Low filter mode 400hz ODP LPMODE Step yes 2.5ms
//300ms/2.5ms = 120counts
Single_Write_MMA8452(0x28,0x78);//300ms
MMA8452Q_Delay(10);
//7、 Set the system interrupt to int1
Single_Write_MMA8452(0x2D,0x08);// Set the interrupt area system CTRL_REG4
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x2E,0x08);// Specify the hardware interrupt pin to INT1 CTRL_REG5
MMA8452Q_Delay(10);
//8、 Activate the chip
MY_Multiple_Read_MMA8452(0x2A,0);// The read value is paid BUF[0]
MMA8452Q_Delay(10);
Single_Write_MMA8452(0x2A,BUF[0]|0x01);// Specify the hardware interrupt pin to INT1 CTRL_REG5
MMA8452Q_Delay(10);
}
The interrupt register corresponding to the pulse is

Every time an interrupt is generated, the priority is to read 0x0C register , Find out what caused the interruption

边栏推荐
- 用C语言开发NES游戏(CC65)07、控制器(和精灵碰撞)
- 界面控件Telerik UI for WPF - 如何使用RadSpreadsheet记录或评论
- Develop NES game (cc65) 07 and controller with C language (collision with spirit)
- Zadig v1.13.0 believes in the power of openness, and workflow connects all values
- [try to hack] UDF raises rights
- First in the country! The two standards of "data product registration" formulated by insight technology and Shandong data were officially released
- 30 years of open source community | 2022 open atom global open source summit 30 years of special activities of open source community were successfully held
- Is it difficult for cloud native machine learning to land? Lingqueyun helps enterprises quickly apply mlops
- 【Base】优化性能到底在优化啥?
- 开源社区三十年 | 2022 开放原子全球开源峰会开源社区三十年专题活动圆满召开
猜你喜欢

数字经济时代的开源数据库创新 | 2022 开放原子全球开源峰会数据库分论坛圆满召开

微创电生理通过注册:年营收1.9亿 微创批量生产上市企业

一台电脑上 多个项目公用一个 公私钥对拉取gerrit服务器代码

Jinshanyun rushes to the dual main listing of Hong Kong stocks: the annual revenue of 9billion is a project supported by Lei Jun

MarkDown简明语法手册

Arduino Pro Mini atmega328p connect and light the first LED (at the same time, record the problem of burning failure stk500_recv)

SuperMap iclient3d for webgl to realize floating thermal map

C for循环内定义int i变量出现的重定义问题
![[half understood] zero value copy](/img/5b/18082c1ea93f2e3bbf4920d73163fd.png)
[half understood] zero value copy

【一知半解】零值拷贝
随机推荐
How can a novice quickly complete the establishment of a website? Come to the free "fitting room" experience
Some API interfaces purchased by Yiwu hope to bring you some help
通过Jenkins 拉取服务器代码 权限不足问题及其他注意事项
Arduino Pro Mini atmega328p connect and light the first LED (at the same time, record the problem of burning failure stk500_recv)
用C语言开发NES游戏(CC65)07、控制器(和精灵碰撞)
Zadig v1.13.0 believes in the power of openness, and workflow connects all values
30 years of open source community | 2022 open atom global open source summit 30 years of special activities of open source community were successfully held
First in the country! The two standards of "data product registration" formulated by insight technology and Shandong data were officially released
Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
Multi Chain and multi currency wallet system development cross chain technology
用C语言开发NES游戏(CC65)03、VRAM缓冲区
1331. Array sequence number conversion: simple simulation question
洪九果品通过聆讯:5个月经营利润9亿 阿里与中国农垦是股东
Ten prohibitions for men and women in love
【一知半解】零值拷贝
卸载 Navicat:正版 MySQL 官方客户端,真香!
Uninstall Navicat: genuine MySQL official client, really fragrant!
Sub database and sub table may not be suitable for your system. Let's talk about how to choose sub database and sub table and newsql
Why do enterprises need the ability of enterprise knowledge management?
上位机和三菱FN2x通信实例