Quality RTOS & Embedded Software

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




Loading

Simple UART Output not working correctly - Cortex-M3

Posted by k3nt00 on December 9, 2014

Hello,

I understand that this is not the optimal way to perform such an action, but I'm in search of why it is not working still. I am aware of how to correctly use semaphores to utilize the resource. If I step through this while debugging, the uart outputs the string just fine. If I just let the task run though without any breakpoints, it seems to output the string characters at random ie: "tstesttses". It is my understanding that wrapping the putstring func with enter and exit critical or suspend and resume all should allow this action to take place uninterrupted. This is the only task running.

Thank you

I am using:

Chip: STM32F107VC (Cortex-M3)

Compiler: arm-none-eabi-gcc

Version: FreeRTOS V8.0.1

~~~~~~~

static void prvUARTTask( void *pvParameters ) {

/* Block for 500ms. */ const TickTypet xDelay = 50 / portTICKPERIOD_MS;

const uint8_t testString[] = "test";

for(;;) {

vTaskDelay( xDelay );

taskENTER_CRITICAL();
{
	USART_PutString(testString);
}
taskEXIT_CRITICAL();

} } ~~~~~~~


Simple UART Output not working correctly - Cortex-M3

Posted by davedoors on December 9, 2014

If USART_PutString() is using interrupts then you won't be able to put the call in a critical section. If that is the only task using the uart then a critical section isnt needed anyway.

Try without the critical section. If that doesnt fix the problem then it must be in the USART_PutString() function. Maybe it is writing a new character to the uart before the last one has been sent.


Simple UART Output not working correctly - Cortex-M3

Posted by k3nt00 on December 9, 2014

Thanks for the reply Dave.

I tried without the critical before of course, the critical was my attempt to rule out any interruptions. The putstring does not use interrupts, its just a simple write data to register func. I'm pretty puzzled by this.

I just simplified it even more

~~~~~ static void prvUARTTask( void *pvParameters ) {

/* Block for 500ms. */ const TickTypet xDelay = 50 / portTICKPERIOD_MS;

const uint8_t testString[] = "test";

for(;;) { vTaskDelay( xDelay );

USART1->DR = ('a' & (uint16_t)0x01FF);
USART1->DR = ('b' & (uint16_t)0x01FF);
USART1->DR = ('c' & (uint16_t)0x01FF);
USART1->DR = ('d' & (uint16_t)0x01FF);
USART1->DR = ('\n' & (uint16_t)0x01FF);

} } ~~~~~~~

and I get this output now: ~~~~~~

   d







        c







             b









                   d

~~~~~~


Simple UART Output not working correctly - Cortex-M3

Posted by rtel on December 9, 2014

Not that it is anything to do with FreeRTOS, but unless there is a FIFO you will have to wait until one character has been transmitted before writing the next. If there is a FIFO then you will have to check the FIFO is not full before writing the next.


Simple UART Output not working correctly - Cortex-M3

Posted by bowerymarc on December 9, 2014

You probably have to wait for each char to actually go out… you’re probably overwriting them. To test, try putting a delay between each write to the UART register that’s greater than the time to TX a byte. M

On Dec 9, 2014, at 3:41 PMEST, k3nt k3nt00@users.sf.net wrote:

Thanks for the reply Dave.

I tried without the critical before of course, the critical was my attempt to rule out any interruptions. The putstring does not use interrupts, its just a simple write data to register func. I'm pretty puzzled by this.

I just simplified it even more

static void prvUARTTask( void *pvParameters ) {

/* Block for 500ms. */ const TickTypet xDelay = 50 / portTICKPERIOD_MS;

const uint8_t testString[] = "test";

for(;;) { vTaskDelay( xDelay );

USART1->DR = ('a' & (uint16_t)0x01FF);
USART1->DR = ('b' & (uint16_t)0x01FF);
USART1->DR = ('c' & (uint16_t)0x01FF);
USART1->DR = ('d' & (uint16_t)0x01FF);
USART1->DR = ('\n' & (uint16_t)0x01FF);

} } and I get this output now:

d

c

b

d

Simple UART Output not working correctly - Cortex-M3

Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/freertos/discussion/382005/

To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/


Simple UART Output not working correctly - Cortex-M3

Posted by k3nt00 on December 9, 2014

I'm using ST's std periph libs. It doesn't do any checking, it just writes to the register like above. This works perfectly fine of course without a scheduler so I'm just trying to understand why and if it is in fact related.

Thanks


Simple UART Output not working correctly - Cortex-M3

Posted by k3nt00 on December 9, 2014

I just recreated this without the freertos scheduler. Same results. My apologies. Thanks for your help!


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




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS