Posted on April 03, 2013 at 12:21Hello I am working on project that includes the programming of USART and I am using the Board from olimex STM32-P-107 with STM32f107VC and for development of the code i am using openOCD Eclipse by Olimex. I need help I have tried alot for getting the data on the serial port but i am not getting sucessful in that. I want to see the result on the serial terminal or on hyper terminal(Putty) So please can you tell me what is wrong with the programming here is the code: void init_USART1(uint32_t baudrate){ /* This is a concept that has to do with the libraries provided by ST * to make development easier the have made up something similar to * classes, called TypeDefs, which actually just define the common * parameters that every peripheral needs to work correctly */ GPIO_InitTypeDef GPIO_InitStruct; // this is for the GPIO pins used as TX and RX USART_InitTypeDef USART_InitStruct; // this is for the USART1 initilization NVIC_InitTypeDef NVIC_InitStructure; // this is used to configure the NVIC (nested vector interrupt controller) /* enable APB1 peripheral clock for USART2 * note that only USART2 connected to APB1 * the other USARTs are connected to APB2 */ RCC_APB2PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); /* enable the peripheral clock for the pins used by * USART2, PB5 for TX and PB6 for RX */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE); /* This sequence sets up the TX and RX pins * so they work correctly with the USART2 peripheral */ GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6; // Pins 5 (TX) and 6 (RX) are used GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; // the pins are configured as alternate function so the USART peripheral has access to them GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; // this defines the IO speed and has nothing to do with the baudrate! GPIO_Init(GPIOD, &GPIO_InitStruct); // now all the values are passed to the GPIO_Init() function which sets the GPIO registers GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE); ///Re-map USART, as USART2 is used as alternate pins on PD5/6 */ /* The RX and TX pins are now connected to their AF * so that the USART2 can take over control of the * pins */ GPIO_PinLockConfig( GPIOD, GPIO_Pin_5); GPIO_PinLockConfig(GPIOD, GPIO_Pin_6); /* Now the USART_InitStruct is used to define the * properties of USART2 */ USART_InitStruct.USART_BaudRate = baudrate; // the baud rate is set to the value we passed into this init function USART_InitStruct.USART_WordLength = USART_WordLength_8b;// we want the data frame size to be 8 bits (standard) USART_InitStruct.USART_StopBits = USART_StopBits_1; // we want 1 stop bit (standard) USART_InitStruct.USART_Parity = USART_Parity_No; // we don't want a parity bit (standard) USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // we don't want flow control (standard) USART_InitStruct.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; // we want to enable the transmitter and the receiver USART_Init(USART2, &USART_InitStruct); // again all the properties are passed to the USART_Init function which takes care of all the bit setting /* Here the USART2 receive interrupt is enabled * and the interrupt controller is configured * to jump to the USART2_IRQHandler() function * if the USART1 receive interrupt occurs */ USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); // enable the USART2 receive interrupt NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; // we want to configure the USART1 interrupts NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// this sets the priority group of the USART1 interrupts NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // this sets the sub priority inside the group NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // the USART1 interrupts are globally enabled NVIC_Init(&NVIC_InitStructure); // the properties are passed to the NVIC_Init function which takes care of the low level stuff // finally this enables the complete USART2 peripheral USART_Cmd(USART2, ENABLE);}int main(void){ init_USART1(9600); // initialize USART1 @ 115200 baud //unsigned int i = 0; //char str[] = ''Welcome to wherever you are\r\n''; while(1) { while(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET); // Wait for Empty USART_SendData(USART2, 0x49); // Send 'I' } while(1); // Don't want to exit }So please help me in the programming.thanks in advance