Stm32L151RCxxx USART Hang issue, Interrupt Based TX/RX simul

General discussion on mikroPascal PRO for ARM.
Post Reply
Author
Message
Ishmeet
Posts: 1
Joined: 13 Jan 2014 14:07

Stm32L151RCxxx USART Hang issue, Interrupt Based TX/RX simul

#1 Post by Ishmeet » 13 Jan 2014 14:11

I am running USART3, on 921600 BaudRate, using RTS CTS, I am always facing system hang when I try to do RX and TX simultaneously. I have pasted the main and IRQ code. IRQ is designed to Transmit a char 'A' while dropping all received data. Hangs happens when we disable USART_ITConfig(USART3, USART_IT_TXE, DISABLE);

Uart_Configuration()...

Code: Select all

USART_ClockInitStructure.USART_Clock = USART_Clock_Disable;
USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low;
USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge;
USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable;
USART_ClockInit(USART3, &USART_ClockInitStructure);

USART_InitStructure.USART_Mode = (USART_Mode_Tx|USART_Mode_Rx);
USART_InitStructure.USART_BaudRate = u32BaudRate;
USART_OverSampling8Cmd(USART3, DISABLE);
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS; 
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;

USART_Init(USART3, &USART_InitStructure);  
USART_ITConfig(USART3,USART_IT_TXE, DISABLE);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
USART_Cmd(USART3, ENABLE);

Main.c ...

uint8_t UART_TransmitData(void)
{
     if(u8IntTxFlag==1)
     {
        u8IntTxFlag=0;
        USART_ITConfig(USART3, USART_IT_TXE, ENABLE);      
        return TRUE;
     }
     return FALSE;
}


void USART3_IRQHandler(void)
{
    /* Implemented full duplex serial communication */
    /*  UART RX  */
    if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
    {
       USART_ReceiveData(USART3);
     }

     /*    UART TX    */
     if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET)
     {
         if(USART_GetFlagStatus(USART3, USART_FLAG_CTS) == RESET)
         {
              while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);
              USART_SendData(USART3, 'A');
              while(USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET);
              USART_ClearFlag(USART3, USART_FLAG_TC);
              USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
              u8IntTxFlag=1;
         }
         else
         {
             USART_ClearFlag(USART3, USART_FLAG_CTS);
         }
         }
}


int main(void)
{
  RCC_ClocksTypeDef RCC_Clocks;

  RCC_Configuration();
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 2000);

  NVIC_Configuration();

  Init_GPIOs();

  SerialUARTConfig(921600, 0, 1, 8, 1);

                while(1)
                {
                                UART_TransmitData();
                                f_SleepMs(5);

                }
                return 0;
}

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Stm32L151RCxxx USART Hang issue, Interrupt Based TX/RX s

#2 Post by filip » 21 Feb 2014 11:22

Hi,

Are you using mikroElektronika compilers ?
Did try to you use default UART library provided there ?

Regards,
Filip.

Post Reply

Return to “mikroPascal PRO for ARM General”