STM32F107+LWIP---如何检查tcp通讯断开?并重新连接
有没有用过数字式mems麦克风的,想问下SPI通讯的问题
stm32f103 CAN通讯多帧发送问题?
STM32F107作为USB主机模拟串口通讯不成功(采用PL2303芯片)
STM32F103C8 LIN通讯例程
求助,丐版J-Link通讯不上
ethernet可以与ethercat通讯吗?
LIS3DH SPI 通讯问题
STM32F373 CAN通讯问题CAN_FLAG_LEC
请教高手看看,STM32F1的多机通讯,地址匹配唤醒问题
GPIO_InitTypeDef GPIO_InitStructure;
SPI_InitTypeDef SPI_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);//¿ªÆôGPIOABµÄÍâÉèʱÖÓ
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);//¿ªÆôAFIOµÄÍâÉèʱÖÓ
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3,ENABLE);//¿ªÆôSPI3µÄÍâÉèʱÖÓ
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
/*ÅäÖÃCS¶Ë¿ÚPA15*/
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_15 ; //Ñ¡ÔñÒª¿ØÖƵÄGPIOA15Òý½Å
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;//ÉèÖÃÒý½ÅģʽΪÍÆÍêÊä³ö
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; //ÉèÖÃÒý½ÅËÙÂÊΪ50MHz
GPIO_Init(GPIOA,&GPIO_InitStructure); //ÒýÓóõʼ»¯º¯Êý£¬³õʼ»¯GPIOA
/*SPI3_MISO--PB4;´øÉÏÀÊäÈë*/
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4 ; //Ñ¡ÔñÒª¿ØÖƵÄGPIOB4Òý½Å
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU; //ÉèÖÃÒý½ÅģʽΪÉÏÀÊäÈë
GPIO_Init(GPIOB,&GPIO_InitStructure); //ÒýÓóõʼ»¯º¯Êý£¬³õʼ»¯GPIOB
/*SPI3_MOSI--PB5;¸´ÓÃÍÆÍìÊä³ö*/
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5 ; //Ñ¡ÔñÒª¿ØÖƵÄGPIOB5Òý½Å
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;//ÉèÖÃÒý½ÅģʽΪ¸´ÓÃÍÆÍì
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; //ÉèÖÃÒý½ÅËÙÂÊΪ50MHz
GPIO_Init(GPIOB,&GPIO_InitStructure); //ÒýÓóõʼ»¯º¯Êý£¬³õʼ»¯GPIOB
/*SPI3_SCK--PB3;¸´ÓÃÍÆÍì*/
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3 ; //Ñ¡ÔñÒª¿ØÖƵÄGPIOB3Òý½Å
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;//ÉèÖÃÒý½ÅģʽΪ¸´ÓÃÍÆÍì
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; //ÉèÖÃÒý½ÅËÙÂÊΪ50MHz
GPIO_Init(GPIOB,&GPIO_InitStructure); //ÒýÓóõʼ»¯º¯Êý£¬³õʼ»¯GPIOB
/*SPI3_WP--PB6;ÍÆÍì*/
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6 ; //Ñ¡ÔñÒª¿ØÖƵÄGPIOB6Òý½Å
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;//ÉèÖÃÒý½ÅģʽΪÍÆÍêÊä³ö
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; //ÉèÖÃÒý½ÅËÙÂÊΪ50MHz
GPIO_Init(GPIOB,&GPIO_InitStructure); //ÒýÓóõʼ»¯º¯Êý£¬³õʼ»¯GPIOB
/*SPI3_HD--PB7;ÍÆÍì*/
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_7 ; //Ñ¡ÔñÒª¿ØÖƵÄGPIOB7Òý½Å
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;//ÉèÖÃÒý½ÅģʽΪÍÆÍêÊä³ö
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz; //ÉèÖÃÒý½ÅËÙÂÊΪ50MHz
GPIO_Init(GPIOB,&GPIO_InitStructure); //ÒýÓóõʼ»¯º¯Êý£¬³õʼ»¯GPIOB
SPI_I2S_DeInit(SPI3);
SPI_EEPROM_CS_HIGH();
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;//Ë«ÏßË«ÏòÈ«Ë«¹¤
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;//Ö÷SPI
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;//8λ֡½á¹¹
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;//ʱÖÓÐü¿Õ¸ß
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;//µÚ¶þ¸öʱÖÓÑØ
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;//Èí¼þÑ¡Ôñ
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;//Ô¤·ÖƵϵÊý4
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;//¸ßλÔÚÇ°
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI3,&SPI_InitStructure);
SPI_Cmd(SPI3,ENABLE);
}
从上传的代码看,至少楼主没有是能SPI时钟:
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3,ENABLE);
评分
查看全部评分
评分
查看全部评分
评分
查看全部评分
你看看你采集波形的这个设备能采集得了,你这个spi的时钟吗?我看你那里设置为4分频,你先自己算一下,你spi的时钟多少M?
评分
查看全部评分