Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

stm32f103 freertos issue - usart2 false setting of RXNE flag.

Posted by engineershrenik on January 8, 2014

Hi, I am using freertos demo for stm32f103x and using stm32f103vct6. Usart 1 is working fine but when i configured usart2 transmit function works fine but usart for receive function RXNE flags is setting falsely hence i am getting garbage data. This is not happening when i am programming two usarts without freertos in keil. Is there any configuration problem? Please help me to solve this issue. I am posting my code too.

void USART2Init(void) { GPIOInitTypeDef GPIO_InitStructure;

     USART_InitTypeDef USART_InitStructure;



     //enable bus clocks

     RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);
     RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);

     //Set USART2 Tx (PA2) as AF push-pull

     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;

     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

     GPIO_Init(GPIOA, &GPIO_InitStructure);

     //Set USART2 Rx (PA3) as input floating

     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

     GPIO_Init(GPIOA, &GPIO_InitStructure);

     USART_InitStructure.USART_BaudRate = 115200;

     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_Mode_Tx;
     USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;



    USART_Init(USART2, &USART_InitStructure);

    //Enable USART2

    USART_Cmd(USART2, ENABLE);

}

/* Usart functions --------------------------------- ------------------------/ /****************************************************************************** * Function Name : SerialPutChar * Description : Print a character on the HyperTerminal * Input : - c: The character to be printed * Output : None * Return : None *******************************************************************************/ void SerialPutChar(u8 c) { USARTSendData(USART2, c); while (USARTGetFlagStatus(USART2, USARTFLAGTXE) == RESET); }

int GetChar (void) { while (USARTGetFlagStatus(USART2, USARTFLAGRXNE) == RESET); return USARTReceiveData(USART2); } /******************************************************************************* * Function Name : SerialPutString * Description : Print a string on the HyperTerminal * Input : - s: The string to be printed * Output : None * Return : None *******************************************************************************/ void SerialPutString(u8 s) { while (s != '0') { SerialPutChar(*s); s ++; } }

static portTASK_FUNCTION(vBTTask,pvParameters) {

int data;

USART2_Init();
printf("Usart2 is initialized Press Key \r\n");
Serial_PutString("test usart string \r\n");

while(1)
{
	 data = GetChar();

SerialPutChar(data); } }

here data variable is getting continuously garbage data using GetChar function.

Please let me know. i guess its freertos related issue only.


stm32f103 freertos issue - usart2 false setting of RXNE flag.

Posted by rtel on January 8, 2014

i guess its freertos related issue only.

I cannot see anything related to FreeRTOS in the code you have posted. Is your FreeRTOS application running ok in every way other than your use of the ST peripheral drivers? If so, then are you using the latest FreeRTOS version with configASSERT() defined, because there were some asserts put in specifically for users of the ST peripheral drivers as those particular drivers require the Cortex-M to be set up in a certain way in order to function correctly with FreeRTOS. However, this related to interrupt priorities, and your code does not look like it is doing anything other than polling registers - so your problem could equally be due to the fact that your polling code is starving all the other tasks of processing time (polling is generally not used in RTOS applications, not without some kind of fast timeout anyway).

Regards.


stm32f103 freertos issue - usart2 false setting of RXNE flag.

Posted by engineershrenik on January 8, 2014

I even tried interrupt for serial but still its going in IRQ again and again even if there is no data on Rx Pin. Even if i disabled complete freertos i get same problem hence i thought it would be problem regarding some rtos configuration.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists