完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嘿,在那里,我有一个问题,我目前的设置,我从MpU6050芯片接收的数据总是相同的。我对这一级别的编程相当陌生,所以我想问一下,如果我错过了一些显而易见的东西。所以我特别使用PIC24FJ128GA204 MCU作为好奇心板的一部分。因此,我使用XC16编译器。我选择使用MCC生成I2C代码,我可以用它与MPU6050加速度表进行接口。我可以看到引脚RB8=SCL,RB9=SDA,VCC在DEV板上连接到5V,接地到GND。我可以使用I2C1MyMraveWrror()来写入I2C设备及其寄存器。我给寄存器写加速度计数据。为了查看返回的数据,我将它保存在一个数组FROMI2C1WAdMaskRead()中,然后在它的内容后面看到一个断点。因此,我运行这个和甜,数组中填充了一些值,我再次运行循环,同样的数据在那里…我试着改变很多不同的东西。试图写入不同的寄存器(它们似乎都返回相同的数据集,甚至是“我是什么”),并试图在数据表中找到一些配置寄存器。我的第一个想法是使用断点,查找变量可能不是最好的方法。任何帮助都会得到极大的赞赏。请找到下面的相关文件和主文件的源代码。如果有帮助的话,我可以提供整个项目。
以上来自于百度翻译 以下为原文 Hey there, I'm having a problem with my current setup where the data I am receiving from the MPU6050 chip is always the same. I'm fairly new to this level of programming so thought I'd ask here if I am missing something obvious first. So specifically I am using the PIC24FJ128GA204 MCU as part of the curiosity board. Therefore I am using the XC16 compiler. I chose to use the MCC to generate the I2C code I could use to interface with the MPU6050 accelerometer. I can see the pins RB8 = SCL, RB9 = SDA, the vcc is attached to 5V on the dev board and ground to GND. From what I understand. I can use the I2C1_MasterWrite() to write to an I2C device and its register. I write to the register for the accelerometer data. To see what data is returned, I hold it in an array from I2C1_MasterRead() and a breakpoint after to look at it's content. So I run this and sweet, the array is populated with some values, I run through the loop again, the same data is there... I've tried changing a lot of different things. Trying to write to different registers(They all seem to return the same set of data, even the "what am I" register.) and trying to write to some config registers I found in the data sheet. My first thought is using a breakpoint and looking in the variable might not be the best way to do it? Any help would be appreciated massively. Please find the relevant documents to me below and the source code of the main file. I can provide the whole project if it would help. /** Generated Main Source File Company: Microchip Technology Inc. File Name: main.c Summary: This is the main file generated using PIC24 / dsPIC33 / PIC32MM MCUs Description: This header file provides implementations for driver APIs for all modules selected in the GUI. Generation Information : Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - pic24-dspic-pic32mm : 1.55 Device : PIC24FJ128GA204 The generated drivers are tested against the following: Compiler : XC16 v1.34 MPLAB : MPLAB X v4.15 */ /* (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this software and any derivatives exclusively with Microchip products. THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE TERMS. */ /* * I2C1: SCL = RB8, SDA = RB9 * I2C2: SCL = RB3, RB2 */ #define FCY 16000000UL #include #include #include #include #include "mcc_generated_files/mcc.h" int main(void) { // initialize the device SYSTEM_Initialize(); uint8_t data[2]; I2C1_MESSAGE_STATUS status; uint16_t address = 0x6B; data[0] = (address >> 8); // high address data[1] = (uint8_t)(address); // low low address I2C1_MasterWrite(data, 2, 0b1101000, &status); while (status != I2C1_MESSAGE_COMPLETE); address = 0x00; data[0] = (address >> 8); // high address data[1] = (uint8_t)(address); // low low address I2C1_MasterWrite(data, 1, 0b1101000, &status); while (status != I2C1_MESSAGE_COMPLETE); while (1) { address = 0x3B; data[0] = (address >> 8); // high address data[1] = (uint8_t)(address); // low low address I2C1_MasterWrite(data, 2, 0b1101000, &status); while (status != I2C1_MESSAGE_COMPLETE); uint8_t accel[20]; I2C1_MasterRead(accel, 20, 0b1101000, &status); while (status != I2C1_MESSAGE_COMPLETE); PORTAbits.RA10 = data; } return -1; } |
|
相关推荐
3个回答
|
|
http://www. vnSn.com /WP内容/上传/ 2015 / 02 /MPU-6000数据表1.PDFHTTPS//www.
以上来自于百度翻译 以下为原文 https://www.invensense.com/wp-content/uploads/2015/02/MPU-6000-Datasheet1.pdf https://www.invensense.co...6000-Register-Map1.pdf |
|
|
|
HI,用断点停止,在调试器中检查数组值是开发过程中正常工作的一种方式。“WOHYAMAMI”寄存器是一个“只读”寄存器,它永远不会改变。对于测量值,传感器设备有一个大的FIFO缓冲器,正在快速测量。如果程序在每一个传输值的断点处停止,那么从一个测量值到下一个测量值几乎没有差别。您可以禁用断点,并且让程序自由运行,同时使传感器颠倒过来。然后从MPLAB X“暂停”按钮中断程序,棕色按钮,Reestabl。在主程序循环中设置一个断点,并在其中运行,以检查更新的值。迈西尔
以上来自于百度翻译 以下为原文 Hi, Stopping with a breakpoint, and examining array values in debugger is a normal way of working during development. The "Who_am_i" register is a "read only" register that is supposed to never change. For measurement values, the sensor device have a large FIFO buffer, and is doing measurements rapidly, so if program stop at breakpoint for every value transferred, there is likely little difference from one measurement to the next. You may disable the breakpoint, and let program run free, while turning the sensor upside down. Then break the program from MPLAB X, "Pause" button, the brown one, Reestablish a breakpoint in the main program loop, and run there, to examine updated values. Mysil |
|
|
|
嘿,Mysil,谢谢你的回复。我读到“WoHyaMayi”寄存器的意思是,如果我试着读加速计寄存器,我得到的数据和我读的“WoHyaMayi”寄存器的数据完全一样。无论我尝试读取哪一个寄存器(尝试从寄存器映射表中选出一组),我总是返回同一组的14字节,SOH;0x1’?0x81'';0x40′′;0xd0′?0x90′′;0xf8′?0xA4′′;0xF6'K′;0x4BETX;0x3′′;0xBA′(′;0x28′o′;0x4f'o′;0x4f′?”0x97′n;0x6EDUBT这意味着很多,但是如果MPU没有被正确配置或者什么的话,它可能是所有寄存器的相同输出吗?我可以看到你从哪里来的断点变化,并尝试了你的建议,但同样的价值再次。谢谢。
以上来自于百度翻译 以下为原文 Hey Mysil, thanks for the reply. What I mean about reading the "Who_am_i" register is that if I try to read the accelerometer register I get the exact same data back than if I tried to read the "Who_am_i" register. No matter which register I try to read(Tried a bunch from the register map sheet), I always get back the same set of 14 bytes. SOH; 0x1 '?'; 0x81 '@'; 0x40 'Ð'; 0xd0 '?'; 0x90 'ø'; 0xf8 '?'; 0xa4 'ö'; 0xf6 'K'; 0x4b ETX; 0x3 'º'; 0xba '('; 0x28 'O'; 0x4f 'O'; 0x4f '?'; 0x97 'n';0x6e Doubt this means much but maybe it's the same output for all registers if the MPU isn't configured properly or something? I can see where you are coming from with the breakpoint change and tried what you suggested but the same values again. Thanks |
|
|
|
只有小组成员才能发言,加入小组>>
5145 浏览 9 评论
1993 浏览 8 评论
1921 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3162 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2218 浏览 5 评论
713浏览 1评论
601浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
484浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
613浏览 0评论
511浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-10 23:57 , Processed in 1.250608 second(s), Total 81, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号