cancel
Showing results for 
Search instead for 
Did you mean: 

Target get disconnected when a specific line is added to the code

hendalage
Associate II
Posted on October 08, 2013 at 20:55

hello friends,

for a requirement of my project, i had to drive an H-bridge motor driver using my STM32F3 DISCO and i implemented the following function just to configure the GPIOs associated with the motor controlling part (two PWM pins for enables and four outputs for motor directions) and i used it for months without any problem. today, when i was going to upload the code, it gives me an error saying 'No target connected' and i had to hold down the reset button, press the upload button and after about two seconds, release the reset button; in order to upload the code to the board. i also ran the code in the debugger and as it started to run, the debugger exits. 

/**

  * @brief  Initializes PWM1(Motor1) and PWM2(Motor2) on PA8 and PA9.

  *  PA10, PA11, PA12, PA13 as digital IOs

  *  PA10->motor_1A PA11->motor_1B

* PA12->motor_2A PA13->motor_2B

  */

void GPIO_Init_Motor(void)

{

// Setup PWM outputs

GPIO_InitTypeDef GPIO_InitStructure;

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_6); // TIM1_CH1 -> Motor1

GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_6); // TIM1_CH2 -> Motor2

// Setup direction IOs

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_InitStructure);

}

after playing with the code for a while, i could narrow it down to where the error is coming from and found out that the ''GPIO_Pin_13'' part occurs the error. when i remove that part from the code, its working without the error. 

anyone there to point me in right direction to solve this problem??

thanks in advance

regards!
1 REPLY 1
Posted on October 08, 2013 at 21:38

It's used by the debug interface, PA13 SWDAT

This should by evident from the F3-DISCO manual, and F303 data sheet.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..