/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / USART2 issues upgrading from 3.4 to 3.7

Username:     
Password:     
             

Forum

# 1   2009-06-22 16:10:22 USART2 issues upgrading from 3.4 to 3.7

adal
Member
Registered: 2009-04-22
Posts: 32

USART2 issues upgrading from 3.4 to 3.7

Hello,

I've been happily working with the Primer2 + CircleOS3.4 connected to an extension board.
I was able to make the STM32 'talk' through USART2 with a processor on the extension board itself. The first version of Circle I got was coming with Raisonance environment.

For some obscure reason, when I replace the Primer2_Circle.elf related to version 3.4 (441k)with the newest (related to 3.7 - 591k) in my project, my application (On STM32 primer 2) is still able to *RECEIVE* from USART2 but *NOT to TRANSMIT* through it.
I've been debugging for long, checking GPIO configurations, RCC_APB2PeriphClockCmd,
I even display GPIOA->CRL, RCC->APB1ENR, RCC->APB2ENR during runs and everything
seems OK.
What I'm I missing?
What kind of upgrade in 3.7 could be disabling my USART2 transmissions?

Adalberto

Offline

 

# 2   2009-06-23 09:42:53 USART2 issues upgrading from 3.4 to 3.7

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: USART2 issues upgrading from 3.4 to 3.7

Do you manage the UART in interrupt mode?

Offline

 

# 3   2009-06-23 10:29:00 USART2 issues upgrading from 3.4 to 3.7

adal
Member
Registered: 2009-04-22
Posts: 32

Re: USART2 issues upgrading from 3.4 to 3.7

Hi Francis,

I actually use interrupts to receive (RX works) but I don't know how they affect transmission.
Here are my USART2 interrupt initializations:

/* Enable USART2 Interrupt (this will have to be moved below)*/
  NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQChannel;
  //NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

...and to transmit I just call the following function:

void USART2_Send_Data(u8* data_buffer, u8 Nb_bytes)
{
  u32 i;

  for (i = 0; i < Nb_bytes; i++)
  {
    USART_SendData(USART2, *(data_buffer + i));
    while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
  }
}


I tested the "while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);" loop,
in order to be sure that is non blocking.

I'm not sure if this answers your question, please let me know,
Adalberto

Offline

 

# 4   2009-06-23 10:58:04 USART2 issues upgrading from 3.4 to 3.7

adal
Member
Registered: 2009-04-22
Posts: 32

Re: USART2 issues upgrading from 3.4 to 3.7

Francis,

in addition to the initializations given in the previous message, I do the following:

  USART_InitStructure.USART_BaudRate = 115200;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  USART_Init(USART2, &USART_InitStructure);
  /* Enable USART2 Receive interrupt */
  USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
  USART_Cmd(USART2, ENABLE);

I hope this helps to put some light over the shadows,
Adalberto

Offline

 

# 5   2009-06-23 12:43:09 USART2 issues upgrading from 3.4 to 3.7

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: USART2 issues upgrading from 3.4 to 3.7

Therefore, I assume that the problem is caused by the irq (priorities?). There are several issues around the IRQ we have to clean up (but after the contest).

Offline

 

# 6   2009-06-23 13:08:44 USART2 issues upgrading from 3.4 to 3.7

adal
Member
Registered: 2009-04-22
Posts: 32

Re: USART2 issues upgrading from 3.4 to 3.7

Francis,

Forgive me if I'm back but there is one point I really don't understand.
In my code I just transmit by assigning a value to the data register and then waiting for the  USART_FLAG_TXE bit to be set with a poll loop (e.g. no interrupts), more specifically:

/*wait TXE bit to return up after write in data register (before writing next  data*/
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);

Can you briefly explain me why you refer to IRQ issues, so that I possibly progress while
the contest takes place?

Adalberto

Offline

 

# 7   2009-06-24 06:40:56 USART2 issues upgrading from 3.4 to 3.7

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: USART2 issues upgrading from 3.4 to 3.7

Sorry... I thought you also enabled the xmit interrupt.
What I could suggest;
- double-check the pin configuration,
- check enable bit for transmitter (see page 659 of the RM)

Offline

 

# 8   2009-06-24 10:36:57 USART2 issues upgrading from 3.4 to 3.7

adal
Member
Registered: 2009-04-22
Posts: 32

Re: USART2 issues upgrading from 3.4 to 3.7

...I assume the bit you refer to is the one that I see at page 463 of the Reference Manual RM0008 (is this what you mean by RM? My manual ends up at page 504)

I display the TE bit of USART2->CR1 register periodically at runtime and it is allways set, the pin configuration was checked.

Please let me know if you have some more hints,
Thanks,
Adalberto

Offline

 

# 9   2009-06-24 14:10:16 USART2 issues upgrading from 3.4 to 3.7

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: USART2 issues upgrading from 3.4 to 3.7

I refer to the same document, but mine has 995 pages ( http://www.st.com/stonline/products/lit … /13902.pdf ). Perhaps you will find more detailled information in the latest release.

Offline

 

# 10   2009-06-25 13:25:54 USART2 issues upgrading from 3.4 to 3.7

kkinnune
New member
Registered: 2007-10-12
Posts: 2

Re: USART2 issues upgrading from 3.4 to 3.7

I had same problem. I solved it by commenting out "Output Compare Timing Mode configuration: Channel1" from TIM_Configuration function. I don't know what is purpose of that configuration code, but everything seems to work without it. I also had to change interrupt priorities to make communication reliable.

Offline

 

# 11   2009-06-26 14:19:04 USART2 issues upgrading from 3.4 to 3.7

adal
Member
Registered: 2009-04-22
Posts: 32

Re: USART2 issues upgrading from 3.4 to 3.7

kkinnune,

looks like things are working with your suggestions but I still didn't have time to understand
why and if turning off output compare on timer2 has implications somewhere else in my demo.

However I couldn't hold my emotions and wait longer to return back to you,
Many Thanks,
Adalberto

Offline

 

# 12   2009-06-29 05:40:14 USART2 issues upgrading from 3.4 to 3.7

kkinnune
New member
Registered: 2007-10-12
Posts: 2

Re: USART2 issues upgrading from 3.4 to 3.7

I think it has something to do with the fact that same pin is used as USART2_TX and TIM2_CH3 pin. Output compare configuration just blocked USART2_TX functionality?

Offline

 

# 13   2010-01-04 13:30:53 USART2 issues upgrading from 3.4 to 3.7

evvaii
New member
Registered: 2009-09-03
Posts: 2

Re: USART2 issues upgrading from 3.4 to 3.7

Usart2 without Circle run fine, but with circle(3.8) TX pin is always high. If I want use circle I must do, when init usart :

void Usart2Init(void) //(u16 baudrate)

{
     
        TIM_DeInit(TIM2); // what i have added as said kkinnune (I think!) !
        USART_InitTypeDef USART_InitStructure;
      GPIO_InitTypeDef GPIO_InitStructure;
      NVIC_InitTypeDef NVIC_InitStructure;

     //bla bla bla
.........................


1) There is a better mode to make Usart running?
2) Francis said: ''Therefore, I assume that the problem is caused by the irq (priorities?). There are several issues around the IRQ we have to clean up (but after the contest).'' There is now a 'cleanup' ?

Many thanks to everybody.

Carlo

Offline

 

Board footer