Hi,
I’m developing code of a custom designed STM32F103RC board with integrated oocdlink JTAG adapter. I’m using OpenOCD (v0.2) to program the chip’s flash. Everything is working fine–compiling code, programming flash, single-stepping through code–except that the processor stops driving its GPIOs after a hard reset.
From an OpenOCD telnet session the following causes the board to begin toggling one of it’s GPIOs:
soft_reset_halt
resume
Unfortunately this (or hard resetting the board) causes the board to stop toggling its GPIO:
reset run
I know the flash is being programmed because I can power cycle the board and still observe the above behavior. After power cycling, the board does not begin to toggle its GPIO until after I issue the soft_reset_halt command.
My start-up code follows. In case it matters, I’m using an external clock source instead of an actual crystal, but I’ve observed the same behavior if I attempt to run from the HSI. I should also mention that it looks as if the processor still runs code after a hard reset because I can use the OpenOCD step commands to see the PC moving around.
Has anybody else observed similar behavior? Any ideas what I could be doing wrong?
Thanks,
Kyle
int main(int argc, char **argv) {
GPIO_InitTypeDef GPIO_InitStructure;
/* Setup the microcontroller system. Initialize the Embedded Flash Interface,
initialize the PLL and update the SystemFrequency variable. */
//SystemInit();ErrorStatus HSEStartUpStatus;
RCC_Configuration();
NVIC_Configuration();
// Make USB-TXD an push-pull output
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
// Enable the clock to the IO pin
RCC_APB2PeriphClockCmd( RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB, ENABLE);
// Enable the clock to the UART
RCC_APB1PeriphClockCmd( RCC_APB1Periph_UART4, ENABLE);
/*
while(1)
{
GPIO_SetBits(GPIOC, GPIO_Pin_10);
Delay(10000);
GPIO_ResetBits(GPIOC, GPIO_Pin_10);
Delay(10000);
}
*/
/* USARTx configured as follow:
-
BaudRate = 9600 baud
-
Word Length = 8 Bits
-
One Stop Bit
-
No parity
-
Hardware flow control disabled (RTS and CTS signals)
-
Receive and transmit enabled
*/
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(UART4, &USART_InitStructure);
USART_Cmd(UART4, ENABLE);
/* Output a message on Hyperterminal using printf function */
while(1)
{
printf(“\n\rUSART Printf Example: retarget the C library printf function to the USART\n\r”);
//USART_SendData(UART4, ‘a’);
Delay(30000);
GPIO_WriteBit (GPIOB, GPIO_Pin_8, Bit_SET);
Delay(30000);
GPIO_WriteBit (GPIOB, GPIO_Pin_8, Bit_RESET);
}
}
void
Delay(__IO uint32_t nCount)
{
for(; nCount != 0; nCount–);
}
void
assert_failed (uint8_t *file, uint32_t line)
{
}
/*******************************************************************************
-
Function Name : NVIC_Configuration
-
Description : Configures Vector Table base location.
-
Input : None
-
Output : None
-
Return : None
*******************************************************************************/
void NVIC_Configuration(void)
{
#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x20000000 */
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
}
/*******************************************************************************
-
Function Name : RCC_Configuration
-
Description : Configures the different system clocks.
-
Input : None
-
Output : None
-
Return : None
*******************************************************************************/
void RCC_Configuration(void)
{
/* RCC system reset(for debug purpose) */
RCC_DeInit();
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);
/* Wait till HSE is ready */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
/* Enable Prefetch Buffer */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
/* HCLK = SYSCLK */
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* PCLK2 = HCLK */
RCC_PCLK2Config(RCC_HCLK_Div1);
/* PCLK1 = HCLK/2 */
RCC_PCLK1Config(RCC_HCLK_Div2);
/* PLLCLK = 8MHz * 12 = 72 MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_12);
/* Enable PLL */
RCC_PLLCmd(ENABLE);
/* Wait till PLL is ready */
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{
}
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while(RCC_GetSYSCLKSource() != 0x08)
{
}
}
}