完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我为STM32F103C8T6编写了以下代码,用于连接AIS3624DQ加速度计。但在检查时,当我读取注册WHO_AM_I(0x0F)时,它应该返回0X32默认值,但它返回0XFF。对于任何输出寄存器,它返回的值与0xFF相同。请帮忙。我知道有些事情是错的,但我没有得到它。
提前致谢。代码如下。 //////// unsigned int x = 0; void main() { GPIO_Digital_Output(& GPIOA_BASE,_GPIO_PINMASK_4); //芯片选择CS SPI1_Init_Advanced(_SPI_FPCLK_DIV2,_SPI_MASTER | _SPI_16_BIT | _SPI_CLK_IDLE_HIGH | _SPI_FIRST_CLK_EDGE_TRANSItiON | _SPI_MSB_FIRST | _SPI_SS_ENABLE | _SPI_SSM_ENABLE | _SPI_SSI_1,& _GPIO_MODULE_SPI1_PA567); Delay_ms(100); 而(1) { GPIOA_ODR.B4 = 0; //芯片选择低 X = SPI1_Read(0X0F); Delay_ms(10); GPIOA_ODR.B4 = 1; ////芯片选择高 } } #stm32f103c8t6 #acceleration#ais3624dq 以上来自于谷歌翻译 以下为原文 the following code i have written for STM32F103C8T6 for interfacing with AIS3624DQ accelerometer. But while checking , when i read register WHO_AM_I (0x0F) it should return me 0X32 default but it is returning me 0XFF. for any output register it is returning me the same value as 0xFF. please help in this. i know some thing is wrong but i am not getting it. thanks in advance. the code is as follows. //////// unsigned int x=0; void main() { GPIO_Digital_Output(&GPIOA_BASE, _GPIO_PINMASK_4); //chip select CS SPI1_Init_Advanced(_SPI_FPCLK_DIV2, _SPI_MASTER | _SPI_16_BIT | _SPI_CLK_IDLE_HIGH | _SPI_FIRST_CLK_EDGE_TRANSITION | _SPI_MSB_FIRST | _SPI_SS_ENABLE | _SPI_SSM_ENABLE | _SPI_SSI_1, &_GPIO_MODULE_SPI1_PA567);Delay_ms(100); while(1) { GPIOA_ODR.B4=0; //chip select low x=SPI1_Read(0X0F); Delay_ms(10); GPIOA_ODR.B4=1; ////chip select high } } #stm32f103c8t6 #acceleration #ais3624dq |
|
相关推荐
7个回答
|
|
也可能是设备未正确接线或未通电。
您应该使用示波器或逻辑分析仪并确认引脚是否以预期的方式运行。 不熟悉您正在使用的库,可能尝试使用SPI的一些SPL或HAL示例代码,确保启用时钟和引脚。你是否在某处启用了GPIOA和SPI1时钟。 以上来自于谷歌翻译 以下为原文 Could also be that device is not wired up properly or not powered. You should perhaps use a scope or logic analyzer and confirm the pins are functioning in the expected manner. Not familiar with the library you're using, perhaps try with some of the SPL or HAL example code for SPI, making sure clocks and pins enabled. Do you enable the GPIOA and SPI1 clocks somewhere. |
|
|
|
时钟和芯片选择引脚正如在RTO上看到的那样工作。还有什么我可以检查的东西?
HAL库的任何指南都是一样的吗? 以上来自于谷歌翻译 以下为原文 Clock and Chip select pin is working as seen on RTO. what additional things i can check ? any guide for HAL library for the same ? |
|
|
|
那么你看到WHOAMI(0x0F)请求出去了,数据又回来了吗?你看到0xFF回来还是0x32?
如果你看到0xFF,你将不得不检查你的设计中AIS3624DQ发生了什么。有线/电源是否正确? 以上来自于谷歌翻译 以下为原文 So do you see the WHOAMI (0x0F) request going out and the data coming back? Do you see 0xFF coming back or 0x32 ? If you see 0xFF you're going to have to examine what's going on with the AIS3624DQ in your design. Is it wired/powered correctly? |
|
|
|
我可以看到0X0F请求在MOSI引脚上输出,并且可以在MISO引脚上看到0xFF输入。
以上来自于谷歌翻译 以下为原文 i can see 0X0F request going out on MOSI pin and can see 0xFF incoming on MISO pin. |
|
|
|
它与所有电容器正确连接。我必须做什么来打断别针
? 以上来自于谷歌翻译 以下为原文 it is wired properly with all capacitors. do i have to do anything to interrupts pin ? |
|
|
|
您需要通过第二个字节计时才能获得对命令的响应。
手册中描述了最小电路和信号 http://www.st.com/content/ccc/resource/technical/document/datasheet/group1/90/87/ca/72/a8/3a/41/32/DM00141453/files/DM00141453.pdf/jcr:内容/翻译/ en.DM00141453.pdf 确保它不处于I2C模式。 确保CS引脚在交易的16个时钟周期内保持低电平。 以上来自于谷歌翻译 以下为原文 You'd need to clock through a second byte to get response to the command. The minimal circuit and signalling are described in the manual http://www.st.com/content/ccc/resource/technical/document/datasheet/group1/90/87/ca/72/a8/3a/41/32/DM00141453/files/DM00141453.pdf/jcr:content/translations/en.DM00141453.pdf Make sure it is not in I2C mode. Make sure the CS pin is low for the 16 clocks of the transaction. |
|
|
|
谢谢你重播。
现在我已经到达,直到从寄存器获取x轴数据。但是在静止位置有很大的噪音。但是当我向加速度计提供运动时,我也能看到xdata的最小和最大变化。我认为某些过滤部分配置不正确。请提出一些建议。还应该在读取两个x轴寄存器时添加多少延迟。 以上来自于谷歌翻译 以下为原文 thanks for replay. right now i have reached till acquiring x axis data from register. but is has enormous amount of noise in stationary position. but also i can see the minimum and maximum changes in xdata when i give motion to the accelerometer. I think some filtering part is not configured properly. please suggest something on this. also how much delay should i add in reading two register of x axis. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2741 浏览 1 评论
3244 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1813 浏览 1 评论
3653 浏览 6 评论
6043 浏览 21 评论
1342浏览 4评论
203浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
356浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
446浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
275浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 14:03 , Processed in 1.389314 second(s), Total 90, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号