TI中文支持网
TI专业的中文技术问题搜集分享网站

CC3200 I2C 引脚 更改 P01、P02

请教一下TI的工程师, 我想把I2C的引脚设置成P03、P04, 我是这样修改的:

//
// Enable Peripheral Clocks //
PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);

//
// Configure PIN_01 for GPIO Input
//
PinTypeGPIO(PIN_01, PIN_MODE_0, false);
GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_IN);

//
// Configure PIN_02 for GPIO Input
//
PinTypeGPIO(PIN_02, PIN_MODE_0, false);
GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_IN);

//
// Configure PIN_03 for I2C0 I2C_SCL
//
MAP_PinTypeI2C(PIN_03, PIN_MODE_5);

//
// Configure PIN_04 for I2C0 I2C_SDA
//
MAP_PinTypeI2C(PIN_04, PIN_MODE_5);

但读写时提示 错误,I2C_MASTER_ERR_ARB_LOST。

请问这是什么原因?

Terry Han:

通过Pin MUX工具直接产生硬件I2C的代码如下:

//*****************************************************************************// pin_mux_config.h//// configure the device pins for different signals//// Copyright (C) 2014 Texas Instruments Incorporated – http://www.ti.com/ // // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met://// Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer.//// Redistributions in binary form must reproduce the above copyright// notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution.//// Neither the name of Texas Instruments Incorporated nor the names of// its contributors may be used to endorse or promote products derived// from this software without specific prior written permission.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.////*****************************************************************************

// This file was automatically generated on 1/13/2017 at 1:34:40 PM// by TI PinMux version ////*****************************************************************************

#ifndef __PIN_MUX_CONFIG_H__#define __PIN_MUX_CONFIG_H__

extern void PinMuxConfig(void);

#endif // __PIN_MUX_CONFIG_H__

//*****************************************************************************// pin_mux_config.c//// configure the device pins for different signals//// Copyright (C) 2014 Texas Instruments Incorporated – http://www.ti.com/ // // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met://// Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer.//// Redistributions in binary form must reproduce the above copyright// notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution.//// Neither the name of Texas Instruments Incorporated nor the names of// its contributors may be used to endorse or promote products derived// from this software without specific prior written permission.//// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.////*****************************************************************************

// This file was automatically generated on 1/13/2017 at 1:34:31 PM// by TI PinMux version ////*****************************************************************************

#include "pin_mux_config.h" #include "hw_types.h"#include "hw_memmap.h"#include "hw_gpio.h"#include "pin.h"#include "gpio.h"#include "prcm.h"

//*****************************************************************************void PinMuxConfig(void){ // // Enable Peripheral Clocks // PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);

// // Configure PIN_03 for I2C0 I2C_SCL // PinTypeI2C(PIN_03, PIN_MODE_5);

// // Configure PIN_04 for I2C0 I2C_SDA // PinTypeI2C(PIN_04, PIN_MODE_5);}

th smi:

回复 Terry Han:

我是通过Pin MUX工具 产生的, 同时也把P01、P02 作为了一个普通的GPIO口。 

最终还是不行。

求解答

Terry Han:

回复 th smi:

同时也把P01、P02 作为了一个普通的GPIO口? 你用P01和P02即做I2C又做普通GPIO? 同一个时间只能配置成一种模式,而且注意I2C需要大约10k的上拉电阻支持。

赞(0)
未经允许不得转载:TI中文支持网 » CC3200 I2C 引脚 更改 P01、P02
分享到: 更多 (0)