2013-07-30 01:08 AM
I have managed to make Flash loader demonstrator work with my FTDI.
Whenever I want to connect to my STM32F4 Discovery board I have to do that in two steps. Firstly I connect proper pins from FTDI to PCB, then I open Flash loader demonstrator, chose my options and click next. Then I get this warning screen: No response from the target. If i close this screen and then again click next I come to flash status page. This is really annoys me, becouse I get this window and I have to make a couple more clicks. Is there any solution to this problem, becouse if I want to programm 50 boards, that would take a lot more time. #stm32f4-uart-programming-isp #stm32f4-uart2013-07-31 08:59 AM
Use command-line mode of FLD.
Edison2014-03-03 04:58 AM
Hi, can someone help me? I need to modify this code to STM32F4 kit. Alternatively, I would need an example of the UART Bluetooth communications (HC-06) module STM32F4. Thanks for all the help :)
#include ''stm32f10x_usart.h''
#include ''stm32f10x_rcc.h'' #include ''stm32f10x_gpio.h'' #include ''misc.h'' int i; //ErrorStatus HSEStartUpStatus; void NVIC_Configuration(void); void GPIO_Configuration(void); void USART_Configuration(void); void USART1_IRQHandler(void); void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount); int main(void) { usart_rxtx(); while(1) { } } /******************************************************************************/ /* STM32F10x Peripherals Interrupt Handlers */ /******************************************************************************/ /** * @brief This function handles USARTx global interrupt request * @param None * @retval None */ void USART1_IRQHandler(void) { if ((USART1->SR & USART_FLAG_RXNE) != (u16)RESET) { i = USART_ReceiveData(USART1); if(i == '1'){ GPIO_WriteBit(GPIOA,GPIO_Pin_8,Bit_SET); // Set '1' on PA8 UARTSend(''LED ON\r\n'',sizeof(''LED ON\r\n'')); // Send message to UART1 } else if(i == '0'){ GPIO_WriteBit(GPIOA,GPIO_Pin_8,Bit_RESET); // Set '0' on PA8 UARTSend(''LED OFF\r\n'',sizeof(''LED OFF\r\n'')); } } } void usart_rxtx(void) { const unsigned char welcome_str[] = '' Welcome to Bluetooth!\r\n''; /* Enable USART1 and GPIOA clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE); /* NVIC Configuration */ NVIC_Configuration(); /* Configure the GPIOs */ GPIO_Configuration(); /* Configure the USART1 */ USART_Configuration(); /* Enable the USART1 Receive interrupt: this interrupt is generated when the USART1 receive data register is not empty */ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); /* print welcome information */ UARTSend(welcome_str, sizeof(welcome_str)); } /******************************************************************************* * Function Name : GPIO_Configuration * Description : Configures the different GPIO ports *******************************************************************************/ void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Configure (PA.8) as output */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); // Save /* Configure USART1 Tx (PA.09) as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Configure USART1 Rx (PA.10) as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); } /******************************************************************************* * Function Name : USART_Configuration * Description : Configures the USART1 *******************************************************************************/ void USART_Configuration(void) { USART_InitTypeDef USART_InitStructure; /* USART1 configuration ------------------------------------------------------*/ USART_InitStructure.USART_BaudRate = 9600; // Baud Rate 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(USART1, &USART_InitStructure); /* Enable USART1 */ USART_Cmd(USART1, ENABLE); } /** * @brief Configures the nested vectored interrupt controller. * @param None * @retval None */ void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; /* Enable the USARTx Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } /******************************************************************************* * Function Name : UARTSend * Description : Send a string to the UART. * Input : - pucBuffer: buffers to be printed. * : - ulCount : buffer's length *******************************************************************************/ void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount) { // // Loop while there are more characters to send. // while(ulCount--) { USART_SendData(USART1, (uint16_t) *pucBuffer++); /* Loop until the end of transmission */ while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) { } } }2014-03-03 05:20 AM
Would probably have been something to start a new topic with.
Be aware that PA9 is not usable for the USART1 on the STM32F4-Discovery board, review schematic.2014-03-03 05:47 AM
Can you help with that? This code works on STM32F1 .. but I need it to work on STM32F4. I will be very grateful :)
2014-03-03 06:51 AM
I'm not going to modify the STM32F4-Discovery design for you, if you want to modify the circuit and remove components you will need to review and understand the schematic. Tip: There is a VERY large bulk capacitor attached to PA9.
// STM32 USART3 (Tx PB.10, Rx PB.11) STM32F4 Discovery - sourcer32@gmail.com
#include ''stm32f4_discovery.h''
/**************************************************************************************/
void RCC_Configuration(void)
{
/* --------------------------- System Clocks Configuration -----------------*/
/* USART3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
/* GPIOB clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
}
/**************************************************************************************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/*-------------------------- GPIO Configuration ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Connect USART pins to AF */
GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3);
}
/**************************************************************************************/
void USART3_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
/* USARTx configuration ------------------------------------------------------*/
/* 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(USART3, &USART_InitStructure);
USART_Cmd(USART3, ENABLE);
}
/**************************************************************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
USART3_Configuration();
while(1)
{
uint16_t Data;
while(USART_GetITStatus(USART3, USART_IT_RXNE) == RESET); // Wait for Char
Data = USART_ReceiveData(USART3); // Collect Char
while(USART_GetITStatus(USART3, USART_IT_TXE) == RESET); // Wait for Empty
USART_SendData(USART3, Data); // Echo Char
}
while(1); // Don't want to exit
}
// STM32 USART2 (Tx PD.5, Rx PD.6) STM32F4 Discovery - sourcer32@gmail.com
#include ''stm32f4_discovery.h''
/**************************************************************************************/
void RCC_Configuration(void)
{
/* --------------------------- System Clocks Configuration -----------------*/
/* USART2 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
/* GPIOD clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
}
/**************************************************************************************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/*-------------------------- GPIO Configuration ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Connect USART pins to AF */
GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_USART2); // USART2_TX
GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_USART2); // USART2_RX
}
/**************************************************************************************/
void USART2_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
/* USARTx configuration ------------------------------------------------------*/
/* USARTx configured as follow:
- BaudRate = 115200 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 = 115200;
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(USART2, &USART_InitStructure);
USART_Cmd(USART2, ENABLE);
}
/**************************************************************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
USART2_Configuration();
while(1)
{
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); // Wait for Empty
USART_SendData(USART2, 0x49); // Send 'I'
}
while(1); // Don't want to exit
}
2014-03-03 08:12 AM
Thank clive1, but the terminal I / O in both examples is blank. Which can be a problem?
2014-03-03 08:32 AM
A scope and/or the debugger are useful tools to find out where your characters get stuck.
2014-03-03 10:04 AM
The STM32 outputs at CMOS levels, consider what you have connected it too, and the signals observed on a scope.