F103(3.3V供电)的mcu和AD7280A直接连在一起,没有加隔离,我配置好SPI后,示波器上看到数据已经发送出去,但是没有数据返回。(在刚开始的时候,有数据返回,但是后来就直接没有了。我spi的
| GPIO_InitTypeDef GPIO_InitStructure; | |
| | |
| RCC_APB2PeriphClockCmd( | RCC_APB2Periph_GPIOA|RCC_APB2Periph_SPI1,ENABLE ); | |
| | |
| //PA5 SCLK ʱÖÓ | |
| //PA7 SDI ´ÓÈëÖ÷³ö | |
| //PA6 SDO ´Ó³öÖ÷Èë | |
| //¾Ý˵¸´ÓÃÊä³öÊÇ¿ÉÒÔÊäÈëµÄ | |
| GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6|GPIO_Pin_7; | |
| GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //¸´ÓÃÍÆÍì | |
| GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; | |
| GPIO_Init(GPIOA, GPIO_InitStructure); | |
| //GPIO_SetBits(GPIOA,GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7); | |
| | | |
| SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //ÉèÖÃSPIµ¥Ïò»òÕßË«ÏòµÄÊý¾Ýģʽ:SPIÉèÖÃΪ˫ÏßË«ÏòÈ«Ë«¹¤ | |
| SPI_InitStructure.SPI_Mode = SPI_Mode_Master; | | //ÉèÖÃSPI¹¤×÷ģʽ:ÉèÖÃΪÖ÷SPI |
| SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; | | //ÉèÖÃSPIµÄÊý¾Ý´óС:SPI·¢ËͽÓÊÕ8λ֡½á¹¹ |
| SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; | | //Ñ¡ÔñÁË´ÐÐʱÖÓµÄÎÈ̬:ʱÖÓÐü¿ÕµÍ |
| SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; | //Êý¾Ý²¶»ñÓÚµÚÒ»¸öʱÖÓÑØ | |
| SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; | | //NSSÐźÅÓÉÓ²¼þ£¨NSS¹Ü½Å£»¹ÊÇÈí¼þ£¨Ê¹ÓÃSSIλ£¹ÜÀí:ÄÚ²¿NSSÐźÅÓÐSSIλ¿ØÖÆ |
| SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256; | | //¶¨Ò岨ÌØÂÊÔ¤·ÖƵµÄÖµ:²¨ÌØÂÊÔ¤·ÖƵֵΪ256 |
| SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; | //Ö¸¶¨Êý¾Ý´«Êä´ÓMSBλ»¹ÊÇLSBλ¿ªÊ¼:Êý¾Ý´«Êä´ÓMSBλ¿ªÊ¼ | |
| SPI_InitStructure.SPI_CRCPolynomial = 7; | //CRCÖµ¼ÆËãµÄ¶àÏîʽ | |
| SPI_Init(SPI1, SPI_InitStructure); //¸ù¾ÝSPI_InitStructÖÐÖ¸¶¨µÄ²ÎÊý³õʼ»¯ÍâÉèSPIx¼Ä´æÆ÷ | |
| | |