STM32F407的硬件I2C,现在的问题是将IO配置完成后SDA,SCL就拉低了,一开始就不正常了啊,配置的步骤ahi按照库文件I2C.C中的说明来配置的。
How to use this driver
* ===================================================================
* 1. Enable peripheral clock using RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2Cx, ENABLE)
* function for I2C1, I2C2 or I2C3.
*
* 2. Enable SDA, SCL and SMBA (when used) GPIO clocks using
* RCC_AHBPeriphClockCmd() function.
*
* 3. Peripherals alternate function:
* - Connect the pin to the desired peripherals' Alternate
* Function (AF) using GPIO_PinAFConfig() function
* - Configure the desired pin in alternate function by:
* GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF
* - Select the type, pull-up/pull-down and output speed via
* GPIO_PuPd, GPIO_OType and GPIO_Speed members
* - Call GPIO_Init() function
* Recommended configuration is Push-Pull, Pull-up, Open-Drain.
* Add an external pull up if necessary (typically 4.7 KOhm).
*
* 4. Program the Mode, duty cycle , Own address, Ack, Speed and Acknowledged
* Address using the I2C_Init() function.
*
* 5. Optionally you can enable/configure the following parameters without
* re-initialization (i.e there is no need to call again I2C_Init() function):
* - Enable the acknowledge feature using I2C_AcknowledgeConfig() function
* - Enable the dual addressing mode using I2C_DualAddressCmd() function
* - Enable the general call using the I2C_GeneralCallCmd() function
* - Enable the clock stretching using I2C_StretchClockCmd() function
* - Enable the fast mode duty cycle using the I2C_FastModeDutyCycleConfig()
* function.
* - Configure the NACK position for Master Receiver mode in case of
* 2 bytes reception using the function I2C_NACKPositionConfig().
* - Enable the PEC Calculation using I2C_CalculatePEC() function
* - For SMBus Mode:
* - Enable the Address Resolution Protocol (ARP) using I2C_ARPCmd() function
* - Configure the SMBusAlert pin using I2C_SMBusAlertConfig() function
*
* 6. Enable the NVIC and the corresponding interrupt using the function
* I2C_ITConfig() if you need to use interrupt mode.
*
* 7. When using the DMA mode
* - Configure the DMA using DMA_Init() function
* - Active the needed channel Request using I2C_DMACmd() or
* I2C_DMALastTransferCmd() function.
* @note When using DMA mode, I2C interrupts may be used at the same time to
* control the communication flow (Start/Stop/Ack... events and errors).
*
* 8. Enable the I2C using the I2C_Cmd() function.
*
* 9. Enable the DMA using the DMA_Cmd() function when using DMA mode in the
* transfers.
的第3条的最后一句话,Recommended configuration is Push-Pull, Pull-up, Open-Drain.这个地方到底应该怎么配置,又是Push-Pull,又是 Open-Drain?
我按照库文件的说明一项一项的来配置,还是只要是把IO初始化完后,SDA就拉低了
|