当前位置:网站首页>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

边栏推荐
- Ten prohibitions for men and women in love
- 开源社区三十年 | 2022 开放原子全球开源峰会开源社区三十年专题活动圆满召开
- Markdown concise grammar manual
- How to build knowledge management system in enterprises and institutions
- Some API interfaces purchased by Yiwu hope to bring you some help
- 【萌新解题】爬楼梯
- JSP自定义标签之自定义分页标签02
- 用C语言开发NES游戏(CC65)02、什么是v-blank?
- 用C语言开发NES游戏(CC65)07、控制器
- 用C语言开发NES游戏(CC65)06、精灵
猜你喜欢

开源汇智创未来 | 2022 开放原子全球开源峰会 OpenAtom openEuler 分论坛圆满召开

Developing NES games with C language (cc65) 11. Metatiles

HC-05蓝牙模块调试从模式和主模式经历

Fusion cloud native, enabling new mileage | 2022 open atom global open source summit cloud native sub forum successfully held

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

论治理与创新 | 2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满召开

Baidu map API adds information window circularly. The window only opens at the last window position and the window information content is the same solution

Using Arduino to develop esp8266 to build a development environment

Not optimistic about Apple making AR, Luo Yonghao: I'll do it myself
随机推荐
Holes in [apue] files
Anhui Jingzhun: Beidou satellite synchronous clock | Beidou synchronous clock | NTP network clock server
Multi Chain and multi currency wallet system development cross chain technology
The usage and Simulation Implementation of vector in STL
上位机和三菱FN2x通信实例
Deployment之滚动更新策略。
界面控件Telerik UI for WPF - 如何使用RadSpreadsheet记录或评论
HMS core audio editing service supports 7 kinds of audio effects to help one-stop audio processing
输入字符串,内有数字和非字符数组,例如A123x456将其中连续的数字作为一个整数,依次存放到一个数组中,如123放到a[0],456放到a[1],并输出a这些数
New progress in the implementation of the industry | the openatom openharmony sub forum of the 2022 open atom global open source summit was successfully held
MarkDown简明语法手册
Jinshanyun rushes to the dual main listing of Hong Kong stocks: the annual revenue of 9billion is a project supported by Lei Jun
Open source database innovation in the era of digital economy | the 2022 open atom global open source summit database sub forum was successfully held
Minimally invasive electrophysiology has passed the registration: a listed enterprise with annual revenue of 190million minimally invasive mass production
SuperMap itablet license module division
恋爱男女十禁
Analysys analysis: focus on users, improve the user experience of mobile banking, and help the growth of user value
Kuzaobao: summary of Web3 encryption industry news on July 13
Exploration on cache design optimization of community like business
New Oriental's single quarter revenue was 524million US dollars, a year-on-year decrease of 56.8%, and 925 learning centers were reduced