2011-08-03 03:30 PM
Hi,
i used to program my stm32 discovery board via usb cable using SWD.
I used some example code and i think i disabled SWD debugging accidently.
Now i cant enable it back, the Keil software i use says that no target is connected and flash download failed. Can anyone help me to enable SWD back ? Is there any ways to reset stm32. Here's the example code i used :
main.c
&sharpinclude ''stm32f10x_lib.h''
/* function prototypes */
void RCC_Configuration(void);
void GPIO_Configuration(void);
void Delay(vu32 nCount);
/* entry point */
int main(void)
{
/* configure clock sources */
RCC_Configuration();
/* configure I/O ports */
GPIO_Configuration();
/* blinking loop */
while (1) {
/* change the PC7 state */
GPIO_WriteBit(GPIOC, GPIO_Pin_8, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_8)));
/* wait */
Delay(0x5FFFF);
Delay(0x5FFFF);
Delay(0x5FFFF);
Delay(0x5FFFF);
Delay(0x5FFFF);
Delay(0x5FFFF);
}
}
/* set up clock sources */
void RCC_Configuration(void)
{
/* reset */
RCC_DeInit();
/* activate HSI (Internal High Speed oscillator) */
RCC_HSICmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);
/* configure prescalers */
RCC_HCLKConfig(RCC_SYSCLK_Div1);// HCLK = 64 MHz, AHB
RCC_PCLK1Config(RCC_HCLK_Div2); // APB1 = 32 MHz
RCC_PCLK2Config(RCC_HCLK_Div1); // APB2 = 64 MHz
/* set up FLASH */
FLASH_SetLatency(FLASH_Latency_2);
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* set up PLL */
RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_16); // 64 MHz
RCC_PLLCmd(ENABLE);
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
/* set up SYSCLK */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); //SYSCLK = PLLCLK => 64 MHz
while (RCC_GetSYSCLKSource() != 0x08);
/* set up peripheral clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE);
}
/* configure I/O ports */
void GPIO_Configuration(void)
{
/* pin configuration parameters */
GPIO_InitTypeDef GPIO_InitStructure;
/* disable SWJ debug port - comment if you are using JTAG */
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);
/* configure PC7 as output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
/* wait */
void Delay(vu32 nCount)
{
while (nCount--);
}
#swd-disable #bootloader-rom2011-08-03 10:28 PM
2011-08-04 11:56 AM
Thank you Donald Becker ! Your advice to boot from ROM bootloader helped. I didnt even had to do anything with jumpers. I put 240R resistor between 5V and Boot pins on my discovery board and pushed RST button. Then i erased flash using ST visual Programmer from ST Toolset. I removed resistor then and Keil recognized my board as it did before
2011-10-11 07:57 PM
Thank you Donald !
I recovered my STM32L-Discovery using your suggestion.2011-10-11 07:58 PM
Thank you for the 240R resistor suggestion.
2011-10-14 03:31 AM
how i change the boot pin? in CN3 connect 2-3 and 1-4 that this?
and next what i need to do?2011-10-14 01:16 PM
The CN3 jumpers control if the embedded STLink (the F103 chip section) is connected to the F100 chip. They are only moved if you want to use the STLink to program an external board.
The Boot0 and Boot1 settings are controlled by ''solder bridge'' jumpers on the board, SB2 and SB16. But it's easiest to just connect to the header pins rather than do anything with the solder bridges.2011-10-14 07:44 PM
I have afraid to do this
1-I just plug a resistor between +5 and boot pin, like rata does 2- push reset bottom 3-Keil recognizer st link and at this time I will able to debug new program in F100 Big thanks for all