硬汉嵌入式论坛

 找回密码
 立即注册
查看: 1051|回复: 4
收起左侧

[技术讨论] 关于STM32F407 SPI从站发送问题

[复制链接]

4

主题

8

回帖

20

积分

新手上路

积分
20
发表于 2024-9-16 08:45:45 | 显示全部楼层 |阅读模式
用STM3F407与Linux芯片做SPI通讯,STM32 的SPI做从站,使用DMA控制收发,目前遇到一个奇怪的问题,用逻辑分析仪抓取数据,发现STM32发送的字节数据,每个之间被插入了0x80,0x81,0x82,0x83这样的数据,但是我的发送buff填充的是01,02,03,04。不知道0x80,0x81,0x82这些数据是哪里来的。附SPI从驱动代码和逻辑分析仪抓取的数据,求助大佬们看下是什么原因。。



#define SPI_MAX_LEN        120
volatile uint8_t Spi_Mosi_Buffer[SPI_MAX_LEN] = {0};
volatile uint8_t Spi_Miso_Buffer[SPI_MAX_LEN] = {0};

uint8_t count = 0;
void spi_salve_init(void)
{
        uint16_t i = 0;
       
        SPI_InitTypeDef SPI_InitSturcter;
        GPIO_InitTypeDef GPIO_InitStructer;
        NVIC_InitTypeDef NVIC_InitStructer;
        DMA_InitTypeDef DMA_initStructer;
       
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
      
        //填充发送buff
       
        for(;i<SPI_MAX_LEN;i++)
                Spi_Miso_Buffer[i] = i&0xff;


       
        //NSS pin
        GPIO_InitStructer.GPIO_Pin = SLAVE_SPI_NSS_PIN;
        GPIO_InitStructer.GPIO_Mode = GPIO_Mode_AF;
        GPIO_InitStructer.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructer.GPIO_PuPd = GPIO_PuPd_NOPULL;
        GPIO_InitStructer.GPIO_Speed = GPIO_Speed_100MHz;
        GPIO_Init(SLAVE_SPI_NSS_PORT, &GPIO_InitStructer);


       
        //MOSI pin
        GPIO_InitStructer.GPIO_Pin = SLAVE_SPI_MOSI_PIN;
        GPIO_InitStructer.GPIO_Mode = GPIO_Mode_AF;
        GPIO_InitStructer.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructer.GPIO_PuPd = GPIO_PuPd_NOPULL;
        GPIO_InitStructer.GPIO_Speed = GPIO_Speed_100MHz;
        GPIO_Init(SLAVE_SPI_MOSI_PORT, &GPIO_InitStructer);


       
        //MISO pin
        GPIO_InitStructer.GPIO_Pin = SLAVE_SPI_MISO_PIN;
        GPIO_InitStructer.GPIO_Mode = GPIO_Mode_AF;
        GPIO_InitStructer.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructer.GPIO_PuPd = GPIO_PuPd_UP;
        GPIO_InitStructer.GPIO_Speed = GPIO_Speed_100MHz;
        GPIO_Init(SLAVE_SPI_MISO_PORT, &GPIO_InitStructer);


       
        //CLK pin
        GPIO_InitStructer.GPIO_Pin = SLAVE_SPI_CLK_PIN;
        GPIO_InitStructer.GPIO_Mode = GPIO_Mode_AF;
        GPIO_InitStructer.GPIO_OType = GPIO_OType_PP;
        GPIO_InitStructer.GPIO_PuPd = GPIO_PuPd_NOPULL;
        GPIO_InitStructer.GPIO_Speed = GPIO_Speed_100MHz;
        GPIO_Init(SLAVE_SPI_CLK_PORT, &GPIO_InitStructer);


       
        /* SPI引脚复用配置 */
        GPIO_PinAFConfig(SLAVE_SPI_NSS_PORT,GPIO_PinSource4,GPIO_AF_SPI1);
        GPIO_PinAFConfig(SLAVE_SPI_MOSI_PORT,GPIO_PinSource5,GPIO_AF_SPI1);
        GPIO_PinAFConfig(SLAVE_SPI_MISO_PORT,GPIO_PinSource6,GPIO_AF_SPI1);
        GPIO_PinAFConfig(SLAVE_SPI_CLK_PORT,GPIO_PinSource7,GPIO_AF_SPI1);

       
        //SPI init
        SPI_InitSturcter.SPI_Mode = SPI_Mode_Slave;
        SPI_InitSturcter.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
        SPI_InitSturcter.SPI_CPHA = SPI_CPHA_2Edge;
        SPI_InitSturcter.SPI_CPOL = SPI_CPOL_High;
        SPI_InitSturcter.SPI_DataSize = SPI_DataSize_8b;
        SPI_InitSturcter.SPI_CRCPolynomial = 7;
        SPI_InitSturcter.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
        SPI_InitSturcter.SPI_FirstBit = SPI_FirstBit_MSB;
        SPI_InitSturcter.SPI_NSS = SPI_NSS_Hard;
        SPI_Init(SPI1, &SPI_InitSturcter);


       
        //SPI MOSI DMA
        DMA_initStructer.DMA_Channel = DMA_Channel_3;            
        DMA_initStructer.DMA_PeripheralBaseAddr = (uint32_t)&SPI1->DR;
        DMA_initStructer.DMA_Memory0BaseAddr = (uint32_t)Spi_Mosi_Buffer;   
        DMA_initStructer.DMA_DIR = DMA_DIR_PeripheralToMemory;               
        DMA_initStructer.DMA_BufferSize = 120;         
        DMA_initStructer.DMA_PeripheralInc = DMA_PeripheralInc_Disable;      
        DMA_initStructer.DMA_MemoryInc = DMA_MemoryInc_Enable;         
        DMA_initStructer.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
        DMA_initStructer.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;     
        DMA_initStructer.DMA_Mode = DMA_Mode_Circular;               
        DMA_initStructer.DMA_Priority = DMA_Priority_High;           
        DMA_initStructer.DMA_FIFOMode = DMA_FIFOMode_Disable;         
        DMA_initStructer.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;     
        DMA_initStructer.DMA_MemoryBurst = DMA_MemoryBurst_Single;        
        DMA_initStructer.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
        DMA_Init(DMA2_Stream2, &DMA_initStructer);


        //enable DMA
        DMA_Cmd(DMA2_Stream2, ENABLE);
        SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Rx, ENABLE);


       
        //SPI MISO DMA
        DMA_initStructer.DMA_Channel = DMA_Channel_3;            
        DMA_initStructer.DMA_PeripheralBaseAddr = (uint32_t)&SPI1->DR;
        DMA_initStructer.DMA_Memory0BaseAddr = (uint32_t)Spi_Miso_Buffer;   
        DMA_initStructer.DMA_DIR = DMA_DIR_MemoryToPeripheral;               
        DMA_initStructer.DMA_BufferSize = 120;           
        DMA_initStructer.DMA_PeripheralInc = DMA_PeripheralInc_Disable;      
        DMA_initStructer.DMA_MemoryInc = DMA_MemoryInc_Enable;         
        DMA_initStructer.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
        DMA_initStructer.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;     
        DMA_initStructer.DMA_Mode = DMA_Mode_Circular;               
        DMA_initStructer.DMA_Priority = DMA_Priority_VeryHigh;           
        DMA_initStructer.DMA_FIFOMode = DMA_FIFOMode_Disable;         
        DMA_initStructer.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;     
        DMA_initStructer.DMA_MemoryBurst = DMA_MemoryBurst_Single;        
        DMA_initStructer.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
        DMA_Init(DMA2_Stream3, &DMA_initStructer);
        DMA_Cmd(DMA2_Stream3, ENABLE);
        SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx, ENABLE);


       
       
        //DMA RX interrupt cifg
        NVIC_InitStructer.NVIC_IRQChannel = DMA2_Stream2_IRQn;
        NVIC_InitStructer.NVIC_IRQChannelPreemptionPriority = 2;
        NVIC_InitStructer.NVIC_IRQChannelSubPriority = 3;
        NVIC_InitStructer.NVIC_IRQChannelCmd = ENABLE;
        NVIC_Init(&NVIC_InitStructer);
        DMA_ITConfig(DMA2_Stream2, DMA_IT_TC, ENABLE);
       
        SPI_Cmd(SPI1, ENABLE); //使能SPI外设
}


//接收DMA中断
void DMA2_Stream2_IRQHandler(void)
{
        if(DMA_GetITStatus(DMA2_Stream2, DMA_IT_TCIF2) == SET)
        {
                /* OPEN SPI RX IT */
                SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_RXNE, ENABLE);
                count++;
               
                DMA_ClearITPendingBit(DMA2_Stream2, DMA_IT_TCIF2);
               
        }
}

1726447372643.png
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117512
QQ
发表于 2024-9-16 10:51:21 | 显示全部楼层
供参考对比

[C] 纯文本查看 复制代码
/**
  ******************************************************************************
  * @file    SPI/SPI_TwoBoards/SPI_DataExchangeDMA/main.c
  * @author  MCD Application Team
  * @version V1.1.0
  * @date    18-January-2013
  * @brief   Main program body
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        [url]http://www.st.com/software_license_agreement_liberty_v2[/url]
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/** @addtogroup STM32F4xx_StdPeriph_Examples
  * @{
  */

/** @addtogroup SPI_DataExchangeDMA
  * @{
  */

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
    uint8_t aTxBuffer[BUFFERSIZE] = "SPI Master/Slave : Communication between two SPI using DMA";
__IO uint8_t aRxBuffer [BUFFERSIZE];
__IO uint8_t ubRxIndex = 0;
__IO uint8_t ubTxIndex = 0;
__IO uint32_t TimeOut = 0;

SPI_InitTypeDef  SPI_InitStructure;

/* Private function prototypes -----------------------------------------------*/
static void SPI_Config(void);
static void SysTickConfig(void);
static TestStatus Buffercmp(uint8_t* pBuffer1, __IO uint8_t* pBuffer2, uint16_t BufferLength);

/* Private functions ---------------------------------------------------------*/

/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40xx.s/startup_stm32f427x.s) before to branch to 
       application main. 
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */ 
  
  /* SPI configuration */
  SPI_Config();
  
  /* SysTick configuration */
  SysTickConfig();
  
  /* LEDs configuration */      
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  
#ifdef SPI_MASTER
  /* Master board configuration */    
  /* Initializes the SPI communication */
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
  SPI_Init(SPIx, &SPI_InitStructure);
  
  /* The Data transfer is performed in the SPI using Direct Memory Access */

  /* Enable DMA SPI TX Stream */
  DMA_Cmd(SPIx_TX_DMA_STREAM,ENABLE);

  /* Enable DMA SPI RX Stream */
  DMA_Cmd(SPIx_RX_DMA_STREAM,ENABLE);

  /* Enable SPI DMA TX Requsts */
  SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Tx, ENABLE);

  /* Enable SPI DMA RX Requsts */
  SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Rx, ENABLE);
  
  /* Configure the Tamper Button */
  STM_EVAL_PBInit(BUTTON_TAMPER,BUTTON_MODE_GPIO);
  
  /* Wait until Tamper Button is pressed */
  while (STM_EVAL_PBGetState(BUTTON_TAMPER));
  
  /* Enable the SPI peripheral */
  SPI_Cmd(SPIx, ENABLE);
  
#endif /* SPI_MASTER */
  
#ifdef SPI_SLAVE
  /* Slave board configuration */
  /* Initializes the SPI communication */
  SPI_InitStructure.SPI_Mode = SPI_Mode_Slave;
  SPI_Init(SPIx, &SPI_InitStructure);

  /* Enable DMA SPI TX Stream */
  DMA_Cmd(SPIx_TX_DMA_STREAM,ENABLE);

  /* Enable DMA SPI RX Stream */
  DMA_Cmd(SPIx_RX_DMA_STREAM,ENABLE);  
  
  /* Enable SPI DMA TX Requsts */
  SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Tx, ENABLE);

  /* Enable SPI DMA RX Requsts */
  SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Rx, ENABLE);

  /* Enable the SPI peripheral */
  SPI_Cmd(SPIx, ENABLE);
 
#endif /* SPI_SLAVE */

  /* Waiting the end of Data transfer */
  while (DMA_GetFlagStatus(SPIx_TX_DMA_STREAM,SPIx_TX_DMA_FLAG_TCIF)==RESET);
  while (DMA_GetFlagStatus(SPIx_RX_DMA_STREAM,SPIx_RX_DMA_FLAG_TCIF)==RESET);
  
  /* Clear DMA Transfer Complete Flags */
  DMA_ClearFlag(SPIx_TX_DMA_STREAM,SPIx_TX_DMA_FLAG_TCIF);
  DMA_ClearFlag(SPIx_RX_DMA_STREAM,SPIx_RX_DMA_FLAG_TCIF);  
  
  /* Disable DMA SPI TX Stream */
  DMA_Cmd(SPIx_TX_DMA_STREAM,DISABLE);

  /* Disable DMA SPI RX Stream */
  DMA_Cmd(SPIx_RX_DMA_STREAM,DISABLE);  
  
  /* Disable SPI DMA TX Requsts */
  SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Tx, DISABLE);

  /* Disable SPI DMA RX Requsts */
  SPI_I2S_DMACmd(SPIx, SPI_I2S_DMAReq_Rx, DISABLE);

  /* Disable the SPI peripheral */
  SPI_Cmd(SPIx, DISABLE);  
  
  if (Buffercmp(aTxBuffer, aRxBuffer, BUFFERSIZE) != FAILED) 
  {
    /* Turn ON LED1 and LED3 */
    STM_EVAL_LEDOn(LED1);
    STM_EVAL_LEDOn(LED3);
    /* Turn OFF LED2 and LED4 */
    STM_EVAL_LEDOff(LED2);
    STM_EVAL_LEDOff(LED4);
  }
  else
  {
    /* Turn OFF LED1 and LED3 */
    STM_EVAL_LEDOff(LED1);
    STM_EVAL_LEDOff(LED3);
    /* Turn ON LED2 and LED4 */
    STM_EVAL_LEDOn(LED2);
    STM_EVAL_LEDOn(LED4);    
  } 
  
  /* Infinite Loop */
  while (1)
  { 
  }  
}

/**
  * @brief  Configures the SPI Peripheral.
  * @param  None
  * @retval None
  */
static void SPI_Config(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
  DMA_InitTypeDef DMA_InitStructure;

  /* Peripheral Clock Enable -------------------------------------------------*/
  /* Enable the SPI clock */
  SPIx_CLK_INIT(SPIx_CLK, ENABLE);
  
  /* Enable GPIO clocks */
  RCC_AHB1PeriphClockCmd(SPIx_SCK_GPIO_CLK | SPIx_MISO_GPIO_CLK | SPIx_MOSI_GPIO_CLK, ENABLE);
  
  /* Enable DMA clock */
  RCC_AHB1PeriphClockCmd(SPIx_DMA_CLK, ENABLE);

  /* SPI GPIO Configuration --------------------------------------------------*/
  /* GPIO Deinitialisation */
  GPIO_DeInit(SPIx_SCK_GPIO_PORT);
  GPIO_DeInit(SPIx_MISO_GPIO_PORT);
  GPIO_DeInit(SPIx_MOSI_GPIO_PORT);
  
  /* Connect SPI pins to AF5 */  
  GPIO_PinAFConfig(SPIx_SCK_GPIO_PORT, SPIx_SCK_SOURCE, SPIx_SCK_AF);
  GPIO_PinAFConfig(SPIx_MISO_GPIO_PORT, SPIx_MISO_SOURCE, SPIx_MISO_AF);    
  GPIO_PinAFConfig(SPIx_MOSI_GPIO_PORT, SPIx_MOSI_SOURCE, SPIx_MOSI_AF);

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;

  /* SPI SCK pin configuration */
  GPIO_InitStructure.GPIO_Pin = SPIx_SCK_PIN;
  GPIO_Init(SPIx_SCK_GPIO_PORT, &GPIO_InitStructure);
  
  /* SPI  MISO pin configuration */
  GPIO_InitStructure.GPIO_Pin =  SPIx_MISO_PIN;
  GPIO_Init(SPIx_MISO_GPIO_PORT, &GPIO_InitStructure);  

  /* SPI  MOSI pin configuration */
  GPIO_InitStructure.GPIO_Pin =  SPIx_MOSI_PIN;
  GPIO_Init(SPIx_MOSI_GPIO_PORT, &GPIO_InitStructure);
 
  /* SPI configuration -------------------------------------------------------*/
  SPI_I2S_DeInit(SPIx);
  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI_InitStructure.SPI_CRCPolynomial = 7;
  
  /* DMA configuration -------------------------------------------------------*/
  /* Deinitialize DMA Streams */
  DMA_DeInit(SPIx_TX_DMA_STREAM);
  DMA_DeInit(SPIx_RX_DMA_STREAM);
  
  /* Configure DMA Initialization Structure */
  DMA_InitStructure.DMA_BufferSize = BUFFERSIZE ;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable ;
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull ;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single ;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
  DMA_InitStructure.DMA_PeripheralBaseAddr =(uint32_t) (&(SPIx->DR)) ;
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  /* Configure TX DMA */
  DMA_InitStructure.DMA_Channel = SPIx_TX_DMA_CHANNEL ;
  DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral ;
  DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)aTxBuffer ;
  DMA_Init(SPIx_TX_DMA_STREAM, &DMA_InitStructure);
  /* Configure RX DMA */
  DMA_InitStructure.DMA_Channel = SPIx_RX_DMA_CHANNEL ;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory ;
  DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)aRxBuffer ; 
  DMA_Init(SPIx_RX_DMA_STREAM, &DMA_InitStructure);
  
}

/**
  * @brief  Configure a SysTick Base time to 10 ms.
  * @param  None
  * @retval None
  */
static void SysTickConfig(void)
{
  /* Setup SysTick Timer for 10ms interrupts  */
  if (SysTick_Config(SystemCoreClock / 100))
  {
    /* Capture error */
    while (1);
  }

  /* Configure the SysTick handler priority */
  NVIC_SetPriority(SysTick_IRQn, 0x0);
}


/**
  * @brief  Compares two buffers.
  * @param  pBuffer1, pBuffer2: buffers to be compared.
  * @param  BufferLength: buffer's length
  * @retval PASSED: pBuffer1 identical to pBuffer2
  *         FAILED: pBuffer1 differs from pBuffer2
  */
static TestStatus Buffercmp(uint8_t* pBuffer1, __IO uint8_t* pBuffer2, uint16_t BufferLength)
{
  while (BufferLength--)
  {
    if (*pBuffer1 != *pBuffer2)
    {
      return FAILED;
    }
    pBuffer1++;
    pBuffer2++;
  }

  return PASSED;
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {}
}
#endif

/**
  * @}
  */

/**
  * @}
  */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
回复

使用道具 举报

4

主题

8

回帖

20

积分

新手上路

积分
20
 楼主| 发表于 2024-9-16 13:57:56 | 显示全部楼层
感谢!!!,我研究研究
回复

使用道具 举报

4

主题

8

回帖

20

积分

新手上路

积分
20
 楼主| 发表于 2024-9-16 14:33:32 | 显示全部楼层
比对了下版主给的代码,找到了问题,发现是和时钟线的GPIO配置,需要选择为上拉模式
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117512
QQ
发表于 2024-9-17 01:30:31 | 显示全部楼层
mingzhangyao123 发表于 2024-9-16 14:33
比对了下版主给的代码,找到了问题,发现是和时钟线的GPIO配置,需要选择为上拉模式

硬件SPI配置内部上拉是一个很重要的好习惯。
回复

使用道具 举报

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

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-8-12 02:55 , Processed in 0.044832 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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