大学生
最后登录1970-1-1
在线时间 小时
注册时间2016-7-21
|
楼主 |
发表于 2017-7-18 11:23:55
|
显示全部楼层
- void AD7606_SPI_GPIO_Config()
- {
-
- GPIO_InitTypeDef GPIO_InitStructure;
- /************SCK1,SDO1**************/
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
-
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5|GPIO_Pin_7;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- /***************SDI1****************/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
-
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- }
- void AD7606_SPI_Config()
- {
- SPI_InitTypeDef SPI_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1,ENABLE);
- /* ÅäÖÃSPIó2¼t2Îêy */
- SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; /* êy¾Y·½Ïò£o2Ïßè«Ë«1¤ */
- SPI_InitStructure.SPI_Mode = SPI_Mode_Master; /* STM32μÄSPI1¤×÷Ä£ê½ £oÖ÷»úÄ£ê½ */
- SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b; /* êy¾Yλ3¤¶è £o 16λ */
- /* SPI_CPOLoíSPI_CPHA½áoÏê1óþö¶¨ê±Öóoíêy¾Y2éÑùμãμÄÏàλ1ØÏμ¡¢
- ±¾àyÅäÖÃ: ×üÏß¿ÕÏDêǸßμçƽ,μú2¸ö±ßÑØ£¨éÏéyÑØ2éÑùêy¾Y)
- */
- SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; /* ê±ÖóéÏéyÑØ2éÑùêy¾Y */
- SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; /* ê±ÖóμÄμú2¸ö±ßÑØ2éÑùêy¾Y */
- SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; /* Ƭѡ¿ØÖÆ·½ê½£oèí¼t¿ØÖÆ */
- SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
- SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; /* êy¾Yλ′«êä′ÎDò£o¸ßλÏè′« */
- SPI_InitStructure.SPI_CRCPolynomial = 7; /* CRC¶àÏîê½¼Ä′æÆ÷£¬¸′λoóÎa7¡£±¾ày3ì2»óà */
- //SPI_InitStructure.SPI_Direction=SPI_Direction_1Line_Rx;//
- SPI_Init(SPI1, &SPI_InitStructure);
- SPI_Cmd(SPI1, ENABLE); /* ê1ÄüSPI */
- }
复制代码
关于SPI就是这么配置的啊,然后我用示波器查看PA5脚的输出,只有20k,而且修改分频系数只会影响波形,但是频率一直都在20k上下 |
|