AnsweredAssumed Answered

Problem with send function in USART1 - STM32VL Discovery

Question asked by santos.favero on Jul 5, 2012
Latest reply on Jul 5, 2012 by Clive One

I'm facing a problem when trying to send data with function USART_SendData(USART1, (uint16_t)resultat) (resultat is a int 32 bits).

When i step by step debugged it, i discovered that my program just enters in an infite loop, due that the flag TC is never set to SET - my conclusion is that the data could not be sent.

Testing with scope, discovered that the PA9 pin stays in a HIGH (or LOW) lvl constantly... 

void envoi_data(int resultat){
        USART_SendData(USART1, (uint16_t)resultat);
        while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)

Here you can find my inits....
void my_gpio(){

  GPIO_InitTypeDef  GPIO_InitStructure;
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO |  RCC_APB2Periph_GPIOA , ENABLE);
  /* Configure the pin */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  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);


void my_usart(){
    USART_InitTypeDef USART_InitStructure;
    USART_ClockInitTypeDef USART_ClockInitStructure;
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
    USART_ClockInit(USART1, &USART_ClockInitStructure);
    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_Mode = USART_Mode_Rx;
    USART_InitStructure.USART_HardwareFlowControl =       USART_HardwareFlowControl_None;
    //Write USART1 parameters
    USART_Init(USART1, &USART_InitStructure);

I'm using IAR workbench....

Thank you!