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


Error in STM32_USART.c

Posted by Al Williams on October 27, 2010
I recently ported FreeRTOS to an STM32 target board and started with the CORTEX_STM32F103_GCC_Rowley demo.

There are a number of small issues there if you try to use the new device library, etc. However, the USART driver has some serious problems. I'd assume no one has actually tried to use the second serial port on the demo.

The biggest issue is the init code has:

RCC_APB2PeriphClockCmd( RCC_APB1Periph_USART2 | RCC_APB2Periph_GPIOA, ENABLE );

This should be:

RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2 , ENABLE );
RCC_APB1PeriphClockCmd( RCC_APB2Periph_AFIO , ENABLE );

The way the code is set up, the AFIO vs GPIO error is harmless, but still wrong. But USART2 never gets lit up using the exisiting driver.

A few other things. The driver turns on DMA for both USARTs but doesn't configure it. This seems to be harmless, but is unnecessary. And the IRQ for USART2 is empty! It is easy to copy the USART1 ISR or -- what I did -- factor it out and make both IRQs call the worker function.

Al W

RE: Error in STM32_USART.c

Posted by Richard on October 28, 2010
Is this because the libraries and/or device has changed since the demo was written, or would it always have been wrong.

The UART drivers are just part of the demo, rather than FreeRTOS itself, so I don't really want a bug tracker opened for this point - but I would be grateful if you could add this information into a change request tracker so it doesn't get lost. Thanks.


RE: Error in STM32_USART.c

Posted by Al Williams on October 28, 2010
Hi Richard,

Yeah I understand it isn't actually part of the OS but I thought it might help someone. It looks like it is JUST in the Rowley demo (I don't see the file STM32_USART.c in any other STM port). There are some changes I made due to the different library version but I didn't mention those. The changes I mentioned above are just arbitrarily wrong. The USART2 is never turned on. There is no reason to turn DMA on for the ports (that I know of). And the USART2 ISR being missing is just incorrect. It looks to me like someone decided to add DMA and port2 to a working piece of code and then stopped in the middle.

I'll open a CR tracker for it. I contributed an LPC port some time back (http://www.drdobbs.com/blog/archives/2010/08/embedded_operat.html) and would be glad to contribute this one (although keep in mind that I have mutated it so it is no longer Rowley-dependent, uses the current STM Libs, has a different Startup etc.


[ 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