OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3513|回复: 2

【请教求助】STM32硬件SPI驱动nrf24l01遇到问题

[复制链接]

1

主题

1

帖子

0

精华

新手上路

积分
34
金钱
34
注册时间
2013-10-16
在线时间
2 小时
发表于 2013-10-17 23:05:32 | 显示全部楼层 |阅读模式
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">用的是STM32 107VCT的最小系统,用SPI1驱动NRF24l01的时候查看返回的STATUS寄存器是0x0E,在初始状态下这个是正确的,但是用SPI2进行操作,就遇到问题了,不管怎么操作,读取的返回值永远是0x1E,以为是NRF怀了,换了一个能用的还是有问题,然后用SPI1 SPI2通信的例程测试了下SPI2能收到正确的数据,说明还是我的配置有问题,但是实在找不出哪里来了。。。。。。。</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">SPI2初始代码:</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">void nrf_spi2_init(void)</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">{</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; GPIO_InitTypeDef GPIO_InitStructure;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitTypeDef SPI_InitStructure;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; /* SPI1 Init, before continuing, start the spio clock */</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE );&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;RCC_APB2PeriphClockCmd( RCC_APB2Periph_AFIO, ENABLE);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI2, ENABLE);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; /* initialize GPIO A5.A6.A7 */</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; GPIO_InitStructure.GPIO_Mode =&nbsp;&nbsp;GPIO_Mode_AF_PP;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; GPIO_Init(GPIOB, &amp;GPIO_InitStructure);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;GPIO B5 --- CSN(SPI NSS&nbsp;&nbsp;chip select)</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;GPIO B6 --- CE (chip mode set)</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;*/</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_5;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_Init(GPIOB, &amp;GPIO_InitStructure);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idle</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NRF_LOW(NRFB_CE_PORT, NRFB_CE_PIN);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NRF_HIGH(NRFB_CSE_PORT, NRFB_CSE_PIN);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO B1 for nRF2401 IRQ&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GPIO_Init(GPIOB, &amp;GPIO_InitStructure);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_Cmd(SPI2, DISABLE); //必须先禁用,才能改变MODE</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; /* configure spi1 */</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_Mode = SPI_Mode_Master;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_InitStructure.SPI_CRCPolynomial = 7;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_Init(SPI2, &amp;SPI_InitStructure);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp;&nbsp;</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; /* enable spi */</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_Cmd(SPI2, ENABLE);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">}</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">之后调用读写函数进行读取:</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">unsigned char spi2_readwritebyte(unsigned char tx)</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">{</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; SPI_I2S_SendData(SPI2, tx);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">&nbsp; &nbsp; return SPI_I2S_ReceiveData(SPI2);</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">}</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">返回值永远是0x1E,要是断开与NRF的物理连接返回0xFF</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">请大侠帮看下啊,万分感谢!</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">另,实在不行想用IO模拟SPI,但是不知道怎么下手,有高手有例程吗?</span><br style="word-wrap:break-word;color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;" />
<span style="color:#222222;font-family:sans-serif;font-size:14px;line-height:21px;background-color:#eeeeee;">多谢啊!!!!!!<br />
<br />
</span>
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165309
金钱
165309
注册时间
2010-12-1
在线时间
2108 小时
发表于 2013-10-17 23:42:36 | 显示全部楼层
参考下我们的例程吧。
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

2

主题

8

帖子

1

精华

初级会员

Rank: 2

积分
195
金钱
195
注册时间
2015-3-16
在线时间
2 小时
发表于 2015-5-16 21:35:20 | 显示全部楼层
我的也是发送失败后状态永远是0x1e,而且总是前几分钟发送接收都没问题,之后就一直死在0x1e的状态中直到几个小时之后
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2024-11-23 12:53

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表