GPIO_InitTypeDef GPIOB_InitStructure; SPI_InitTypeDef SPI_InitStructure; void RCC_Configuration(void) { RCC_DeInit(); SystemInit(); RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA |RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO , ENABLE); RCC_APB2PeriphClockCmd( RCC_APB2Periph_SPI1 , ENABLE); } void GPIO_Configuration(void) { GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SPI1,ENABLE); //SCK-PB3,MOSI-PB5 GPIOB_InitStructure.GPIO_Pin = GPIO_Pin_3|GPIO_Pin_5; GPIOB_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIOB_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOB,&GPIOB_InitStructure); //MISO-PB4 GPIOB_InitStructure.GPIO_Pin = GPIO_Pin_4; GPIOB_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOB,&GPIOB_InitStructure); } u8 SPI1_ReadWriteByte(u8 TxData) { SPI1->DR = TxData; while (!(SPI1->SR & 0x01)); return (SPI1->DR); } void SPI_Configuration(void) { SPI_Cmd(SPI1, DISABLE); SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; SPI_InitStructure.SPI_Mode = SPI_Mode_Master; 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_128;//56M/128=437.5K SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; SPI_Init(SPI1, &SPI_InitStructure); SPI_Cmd(SPI1, ENABLE); SPI1_ReadWriteByte(0xff); } 在SPI1_ReadWriteByte(0xff);处设置断点,单步运行,发现SPI1->DR 寄存器数据一直显示为0x00.请各位技术大牛帮忙看看 |
【MCU实战经验】基于STM32F103C8T6的hart总线调试器设计
求教STM32F103进入STOP模式后用外部中断唤醒的问题
基于STM32F103RCT6的无源蜂鸣器音乐播放(生日快乐歌)
STM32F103c8t6有没有DAC 功能?
STM32F103x中文数据手册
新手求教,为何在我电脑上找不到STM32F1Xx.h文件
金龙107例程汇总(STM32F107)
万利STM32F107VC 原理图
STM32F103 ADC多通道检测必须要DMA吗?
【官方例程】STM32F107以太网官方例程
你这分得的真爽。
你这分得也很爽。