AnsweredAssumed Answered

STM32F4 USART

Question asked by rao.nakul on Sep 30, 2012
Latest reply on Oct 3, 2012 by rao.nakul
I am using the following code to transfer an array of 100 elements to the PC via UART. I am not able to understand what my mistake is. Can someone please point out my mistake. Here is the code

USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;


   /* Peripheral Clock Enable -------------------------------------------------*/
   /* Enable GPIO clock */
   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC , ENABLE);
   
   /* Enable USART clock */
   RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);


   /* Connect USART pins to AF7 */
   
   GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_USART3);
   GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_USART3);
   
   /* Configure USART Tx and Rx as alternate function push-pull */
   
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
   
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
   GPIO_Init(GPIOC, &GPIO_InitStructure);
   
   USART_InitStructure.USART_BaudRate = 9600;
   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
   USART_InitStructure.USART_StopBits = USART_StopBits_1;


   /* When using Parity the word length must be configured to 9 bits */
   USART_InitStructure.USART_Parity = USART_Parity_No;


   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
   USART_InitStructure.USART_Mode = USART_Mode_Tx;
   USART_Init(USART3, &USART_InitStructure);
   
   USART_ClearFlag(USART3, USART_FLAG_TC);
   
   /* Enable USART */
   USART_Cmd(USART3, ENABLE);


   SRAM_ReadBuffer(RxBuffer, 0x00, 100);
      for(i=0;i<100;i++)
      {
                USART_SendData(USART3, RxBuffer[i]);
           
           Delay(1000);
***           while(USART_GetFlagStatus(USART3,USART_FLAG_TC) == RESET)
           {}
           USART_ClearFlag(USART3, USART_FLAG_TC);
      }


The line marked as ***. I have tried it with both set and reset but to no avail.

Outcomes