cancel
Showing results for 
Search instead for 
Did you mean: 

Disable JTAG-DP + SW-DP for STM32F303

vaibhav23
Associate II
Posted on May 28, 2014 at 08:40

Hi, I have been looking around in the forums for a solution for my target mcu, STM32F I want to use the I2C1_SDA/SCL on PA14/PA These pins are used for JTA-DP and SW-DP. I want to disable this and use only the I2C peripheral.

The solution for the STM32F1 targets are like this:

if
((pin == PA_13) || (pin == PA_14)) {
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
}
if
((pin == PA_15) || (pin == PB_3) || (pin == PB_4)) {
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
} 

http://mbed.org/users/mbed_official/code/mbed-src/file/a51c77007319/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/pinmap.c The code above does not compile, since the defines do not exist on the F3. The solution for the F3 arch does not seem to exist. I was wondering what I could do to get I2C peripheral on PA14/15 working and disabling JTAG/SWD. Thank you. #cpal #stm32f3 #i2c #stm32f3. #swd-disable #i2c-cpal #jtag
5 REPLIES 5
Posted on May 28, 2014 at 15:40

I think you just have to reprogram the GPIO pins via GPIO_Init(), and change AF settings via GPIO_PinAFConfig()

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
vaibhav23
Associate II
Posted on May 30, 2014 at 08:04

Ok clive1 thank you.

I manage to get the GPIO working, I guess I had some issues in my code. Now what I would like to do is get the CPAL I2C library working, and the default port it is set to works. I just want to change the I2C functionality onto the PA14/PA15 here is the code that is there, and what I changed in the stm32f30x_i2c_cpal_hal.h file.

#define CPAL_I2C1_SCL_GPIO_PORT GPIOB
#define CPAL_I2C1_SCL_GPIO_CLK RCC_AHBPeriph_GPIOB
#define CPAL_I2C1_SCL_GPIO_PIN GPIO_Pin_6
#define CPAL_I2C1_SCL_GPIO_PINSOURCE GPIO_PinSource6
#define CPAL_I2C1_SDA_GPIO_PORT GPIOB
#define CPAL_I2C1_SDA_GPIO_CLK RCC_AHBPeriph_GPIOB
#define CPAL_I2C1_SDA_GPIO_PIN GPIO_Pin_7
#define CPAL_I2C1_SDA_GPIO_PINSOURCE GPIO_PinSource7
/*-----------I2C2 Device -----------*/
#define CPAL_I2C1_SCL_GPIO_PORT GPIOA
#define CPAL_I2C1_SCL_GPIO_CLK RCC_AHBPeriph_GPIOA
#define CPAL_I2C1_SCL_GPIO_PIN GPIO_Pin_15
#define CPAL_I2C1_SCL_GPIO_PINSOURCE GPIO_PinSource15
#define CPAL_I2C1_SDA_GPIO_PORT GPIOA
#define CPAL_I2C1_SDA_GPIO_CLK RCC_AHBPeriph_GPIOA
#define CPAL_I2C1_SDA_GPIO_PIN GPIO_Pin_14
#define CPAL_I2C1_SDA_GPIO_PINSOURCE GPIO_PinSource14
/*-----------I2C2 Device -----------*/

But this does not seem to work, I cannot find what else I have to change to get the I2C CPAL library working. I would appreciate any advice. From what I understand the CPAL library handles all the GPIO structure initializing. Thanks.
chen
Associate II
Posted on May 30, 2014 at 10:48

Hi

''Now what I would like to do is get the CPAL I2C library working, and the default port it is set to works. I just want to change the I2C functionality onto the PA14/PA15''

First - check that the I2C peripheral is accessible on PA14 and 15

Then

''I think you just have to reprogram the GPIO pins via GPIO_Init(), and

change AF settings via GPIO_PinAFConfig()

''

vaibhav23
Associate II
Posted on May 31, 2014 at 01:00

/* -- Section 1 : **** Device IO Pins Selection ****

Description: This section allows user to choose IO Pins for each device if possible (in accordance with

used product: some products have only one possibility for the IO pins).

Each device instance (I2C1, I2C2 ..) has its specific defines: one for each Pin.

For each device instance, you will change existing defines with adequate IO Pins and Port

( Refer to Product Pin mapping in related datasheet).*/

/* To configure SCL and SDA Pin change these defines with adequate value :

#define CPAL_I2C1_SCL_GPIO_PORT GPIOX (X : Name of the GPIO PORT (A,B,C,....))

#define CPAL_I2C1_SCL_GPIO_CLK RCC_APB2Periph_GPIOX (X : Name of the GPIO PORT (A,B,C,....))

#define CPAL_I2C1_SCL_GPIO_PIN GPIO_Pin_X (X : Pin number (1,2,3,....))

#define CPAL_I2C1_SCL_GPIO_PINSOURCE GPIO_PinSourceX (X : Pin number (1,2,3,....))

#define CPAL_I2C1_SDA_GPIO_PORT GPIOX (X : Name of the GPIO PORT (A,B,C,....))

#define CPAL_I2C1_SDA_GPIO_CLK RCC_APB2Periph_GPIOX (X : Name of the GPIO PORT (A,B,C,....))

#define CPAL_I2C1_SDA_GPIO_PIN GPIO_Pin_X (X : Pin number (1,2,3,....))

#define CPAL_I2C1_SDA_GPIO_PINSOURCE GPIO_PinSourceX (X : Pin number (1,2,3,....)) */

/* IO Pins selection possibilities

|--------|---------|--------------|-----------|------------------|-------------------------|

| Device | I2C PIN | GPIO_PIN | GPIO_PORT | GPIO_PinSource | GPIO_CLK |

|--------|---------|--------------|-----------|------------------|-------------------------|

| | | GPIO_Pin_6 | GPIOB | GPIO_PinSource6 | RCC_AHBPeriph_GPIOB |

| | |--------------|-----------|------------------|-------------------------|

| | SCL | GPIO_Pin_8 | GPIOB | GPIO_PinSource8 | RCC_AHBPeriph_GPIOB |

| | |--------------|-----------|------------------|-------------------------|

| | | GPIO_Pin_15 | GPIOA | GPIO_PinSource15 | RCC_AHBPeriph_GPIOA |

| I2C1 |---------|--------------|-----------|------------------|-------------------------|

| | | GPIO_Pin_7 | GPIOB | GPIO_PinSource7 | RCC_AHBPeriph_GPIOB |

| | |--------------|-----------|------------------|-------------------------|

| | SDA | GPIO_Pin_9 | GPIOB | GPIO_PinSource9 | RCC_AHBPeriph_GPIOB |

|

| |--------------|-----------|------------------|-------------------------|

| | | GPIO_Pin_14 | GPIOA | GPIO_PinSource14 | RCC_AHBPeriph_GPIOA |

|--------|---------|--------------|-----------|------------------|-------------------------|

| | | GPIO_Pin_1 | GPIOF | GPIO_PinSource1 | RCC_AHBPeriph_GPIOF |

| | SCL |--------------|-----------|------------------|-------------------------|

| | | GPIO_Pin_6 | GPIOF | GPIO_PinSource6 | RCC_AHBPeriph_GPIOF |

| | |--------------|-----------|------------------|-------------------------|

| | | GPIO_Pin_9 | GPIOA | GPIO_PinSource9 | RCC_AHBPeriph_GPIOA |

| I2C2 |---------|--------------|-----------|------------------|-------------------------|

| | | GPIO_Pin_0 | GPIOF | GPIO_PinSource0 | RCC_AHBPeriph_GPIOF |

| | | GPIO_Pin_10 | GPIOA | GPIO_PinSource10 | RCC_AHBPeriph_GPIOA |

|--------|---------|--------------|-----------|------------------|-------------------------|

*/

From what the comments in the library say, that it is possible to use PA15/PA14 as SCL/SDA pins respectively. The datasheet for the STM32F3 series also says that PA15/PA14 have the I2C1 function. From the code in the library, the GPIO pins already configured by the CPAL library. The GPIO_Pin_15/14 are suppose to be used for I2C1 function.

Thank you.

Posted on May 31, 2014 at 02:17

Ok, what exactly isn't working here?

It's not compiling? Not accessing the I2C device?

Do you have any JTAG/SWD connected to the device?

Do you have pull-ups on your I2C lines?

What board is this? Do you have a schematic for this section?
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..