FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [January 2014 Threads]
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.
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.
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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.