/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / USART2 initialization trouble

Username:     
Password:     
             

Forum

# 1   2011-09-30 08:54:14 USART2 initialization trouble

vvvlk
New member
Registered: 2010-03-11
Posts: 3

USART2 initialization trouble

Usually USART2 initialized correct and work correctly.
But some times after VDD pull up, USART2 initialize procedure is executed correctly (software correctly) and then
when I send the string to USART and CPU NVIC has interrupt signal from USART Tx
BUT!!!  Tx pin has not any activity.
And next observation. If after VDD pull up USART initialized correctly then HW reset or SW reset do not knock USART down.  And If after VDD pull up USART NOT initialized correctly then NO HW reset and NO SW reset do not bring back USART to life.
Thus that is the problem of VDD initialization.
Has any body any ideas???

Offline

 

# 2   2011-10-03 13:30:12 USART2 initialization trouble

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: USART2 initialization trouble

On which platform do you get this issue ?

Offline

 

# 3   2011-10-03 14:03:39 USART2 initialization trouble

vvvlk
New member
Registered: 2010-03-11
Posts: 3

Re: USART2 initialization trouble

Device is: STM32 Primer2
OS: version 3.8
We tested 30 devices.
~65% is working corectly (without problem).
And near 35 % devices works with present problem.

USART2 works via NVIC (using Rx, Tx interupt ), but I check the same situation with disable interupt and software checking Rx,Tx flags.

And initiualization code:

void USART2_Config( void )
    {
    NVIC_InitTypeDef NVIC_InitStructure;
    USART_InitTypeDef USART_InitStructure;
    GPIO_InitTypeDef GPIO_InitStructure;

      /* Enable PORTA clocks */
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, DISABLE);
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);
      /* Enable USART2 clocks */
     RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);

      /* Configure USART2 Tx (PA.2) as alternate function push-pull */
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_Init(GPIOA, &GPIO_InitStructure);

    /* Configure USART2 Rx (PA.3) as input push-up */
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//IN_FLOATING;
      GPIO_Init(GPIOA, &GPIO_InitStructure);
     
      /* USART2 configuration ------------------------------------------------------*/
      /* USART2 configured as follow:
            - BaudRate = 9600 baud
            - Word Length = 8 Bits
            - One Stop Bit
            - No pbar_dataty
            - Hardware flow control disabled (RTS and CTS signals)
            - Receive and transmit enabled
            - USART Clock disabled
            - USART CPOL: Clock is active low
            - USART CPHA: Data is captured on the second edge
            - USART LastBit: The clock pulse of the last data bit is not output to
                             the SCLK pin
      */
      USART_InitStructure.USART_BaudRate = 9600; //
      USART_InitStructure.USART_WordLength = USART_WordLength_8b;
      USART_InitStructure.USART_StopBits = USART_StopBits_1;
      USART_InitStructure.USART_Pbar_dataty = USART_Pbar_dataty_No;
      USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
      USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
      USART_Init(USART2, &USART_InitStructure);

    NVIC_PriorityGroupConfig( NVIC_PriorityGroup_1 );
    NVIC_InitStructure.NVIC_IRQChannel                    = USART2_IRQChannel;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority         = 2;
    NVIC_InitStructure.NVIC_IRQChannelCmd                 = ENABLE;
    NVIC_Init( &NVIC_InitStructure );
   
    UTIL_SetIrqHandler(USART2_IRQHandler, (tHandler)USART2_Handler);  //pointing out the handler

      /* Enable the USART2 */
      USART_Cmd(USART2, ENABLE);
     
      /* USART2 Receive and Transmite interrupt */
      USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
      USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
     
    }

Offline

 

# 4   2011-10-10 07:17:58 USART2 initialization trouble

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: USART2 initialization trouble

On Primer2 platform, if you try to send data on USART2 (pin PA2), you face the bug with the TIM2 configuration.
Take a look at the correspondent posts.

In fact, the problem is the configuration of TIM2.
The bug is fixed on 4.1 CircleOS version.
Meanwhile the workaround is always "TIM_DeInit(TIM2);"

Offline

 

# 5   2011-10-10 08:23:27 USART2 initialization trouble

vvvlk
New member
Registered: 2010-03-11
Posts: 3

Re: USART2 initialization trouble

Thank's. I see result, problem is fixed!!!

Offline

 

Board footer