Quality RTOS & Embedded Software

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


Loading

FreeRTOSV7.1.0 on PIC18F25k80 Queue - Uart

Posted by Voloviq on February 10, 2012
Hello,

I ported example number 2 for pic18f452 to pic18f25k80. Porting sucesful everything compile etc.

When I create one task just only one task which receive some data from queue UART1 system restar in some period (period is different all the times).

Below my configuration:

Linker script:

// File: 18f25k80_g.lkr
// Generic linker script for the PIC18F25K80 processor

#DEFINE _CODEEND _DEBUGCODESTART - 1
#DEFINE _CEND _CODEEND + _DEBUGCODELEN
#DEFINE _DATAEND _DEBUGDATASTART - 1
#DEFINE _DEND _DATAEND + _DEBUGDATALEN

LIBPATH .

#IFDEF _CRUNTIME
#IFDEF _EXTENDEDMODE
FILES c018i_e.o
FILES clib_e.lib
FILES p18F25K80_e.lib

#ELSE
FILES c018i.o
FILES clib.lib
FILES p18F25K80.lib
#FI

#FI

#IFDEF _DEBUGCODESTART
CODEPAGE NAME=page START=0x0 END=_CODEEND
CODEPAGE NAME=debug START=_DEBUGCODESTART END=_CEND PROTECTED
#ELSE
CODEPAGE NAME=page START=0x0 END=0x7FFF
#FI

CODEPAGE NAME=userid START=0x200000 END=0x200007 PROTECTED
CODEPAGE NAME=cfgmem START=0x300000 END=0x30000D PROTECTED
CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
CODEPAGE NAME=eedata START=0xF00000 END=0xF003FF PROTECTED

#IFDEF _EXTENDEDMODE
DATABANK NAME=gpre START=0x0 END=0x5F
#ELSE
ACCESSBANK NAME=accessram START=0x0 END=0x5F
#FI

//DATABANK NAME=gpr0 START=0x60 END=0xFF
//DATABANK NAME=gpr1 START=0x100 END=0x1FF
//DATABANK NAME=gpr2 START=0x200 END=0x2FF
//DATABANK NAME=gpr3 START=0x300 END=0x3FF
//DATABANK NAME=gpr4 START=0x400 END=0x4FF
//DATABANK NAME=gpr5 START=0x500 END=0x5FF
//DATABANK NAME=gpr6 START=0x600 END=0x6FF
//DATABANK NAME=gpr7 START=0x700 END=0x7FF
//DATABANK NAME=gpr8 START=0x800 END=0x8FF
//DATABANK NAME=gpr9 START=0x900 END=0x9FF
//DATABANK NAME=gpr10 START=0xA00 END=0xAFF
//DATABANK NAME=gpr11 START=0xB00 END=0xBFF
//DATABANK NAME=gpr12 START=0xC00 END=0xCFF
DATABANK NAME=BIG_BLOCK START=0x60 END=0xAFF
DATABANK NAME=gpr12 START=0xB00 END=0xCFF PROTECTED

#IFDEF _DEBUGDATASTART
DATABANK NAME=gpr13 START=0xD00 END=_DATAEND
DATABANK NAME=dbgspr START=_DEBUGDATASTART END=_DEND PROTECTED
#ELSE //no debug
DATABANK NAME=gpr13 START=0xD00 END=0xDFF
#FI

DATABANK NAME=gpr14 START=0xE00 END=0xE40
DATABANK NAME=sfr14 START=0xE41 END=0xEFF PROTECTED
DATABANK NAME=sfr15 START=0xF00 END=0xF5F PROTECTED
ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED

#IFDEF _CRUNTIME
SECTION NAME=CONFIG ROM=cfgmem
#IFDEF _DEBUGDATASTART
STACK SIZE=0x1FF RAM=gpr12
#ELSE
STACK SIZE=0x1FF RAM=gpr12
#FI
#FI


Task creation

xTaskCreate( Receiver_Tmp, ( const char * const ) "Urt_Rx", 250, NULL, 1, NULL );

Task definition

static void Receiver_Tmp( void *pvParameters )
{
unsigned char i;
char bt;

portTickType xUart1Rate, xLastUart1Time;

/* The parameters are not used. */
( void ) pvParameters;

/* Calculate the LED and flash rate. */
portENTER_CRITICAL();
{
i = 0;
bt = 0;
xUart1Rate = 10;

/* We need to initialise xLastFlashTime prior to the first call to
vTaskDelayUntil(). */
xLastUart1Time = xTaskGetTickCount();

for(i = 0; i < inputRECEIVER_BUFFER; i++)
str_1 = 0x00;

i = 0;
}
portEXIT_CRITICAL();

for( ;; )
{
while(xSerial1GetChar( NULL, &bt, mainNO_BLOCK ))
{
str_1 = bt;

if(bt == 0x03)
{
PORTBbits.RB5 = !PORTBbits.RB5;
//Emar_Frame_Analyze( str_1, &cfr );
bt = 0;
i = 0;
}
else
{
i++;
i %= inputRECEIVER_BUFFER;
}
}

vTaskDelayUntil( &xLastUart1Time, xUart1Rate );

}
}


Queue definition:

xRx1edChars = xQueueCreate( 150, ( unsigned portBASE_TYPE ) sizeof( unsigned char ) );
xCharsForTx1 = xQueueCreate( 50, ( unsigned portBASE_TYPE ) sizeof( unsigned char ) );


Frames which incoming to uart receive come with 38400 bd usualy 20 bytes with gap between consecutive frames 200[ms]

Can anyone help me to resolve this problem because my idea was finished now ;(

BR VOLOVIQ

RE: FreeRTOSV7.1.0 on PIC18F25k80 Queue - Uart

Posted by Richard on February 11, 2012
PIC18 is not an ideal target in this scenario. That said...

If the code is linking then your linker script is probably ok, at least it is defining a block large enough to hold a heap. Did you also check the math and temp data section sizes, which can vary with builds?
Does your system work as you expect for a while, then reset, or not work at all before resetting?

Regards.

RE: FreeRTOSV7.1.0 on PIC18F25k80 Queue - Uart

Posted by Voloviq on February 14, 2012
Hi,

first of all thanks for reply.

I discover that in generic example number 2 in flash led section at the end was invoke function named xTaskResumeAll( void ) as I good remember. When I remove this function system seems to be work as shoud be but sometimes also hung up. This hung up is probably caused be me probably some array but I must it check very careful.

One question concerning to this function xTaskResumeAll( void );.

What this function do indeed?

Where is located math and temp data section sizes definitions ?

Thanks for any answers
BR Voloviq

RE: FreeRTOSV7.1.0 on PIC18F25k80 Queue - Uart

Posted by Voloviq on February 14, 2012
Sorry I forgotten one thing,

all system start and work well for 10minutes, 20minuts sometimes 60minutes and hung up. Hung up all tasks. Do exist some procedure to quickly find leakage because stack protect doesn't as should be.

Regards Voloviq

RE: FreeRTOSV7.1.0 on PIC18F25k80 Queue - Uart

Posted by Voloviq on February 15, 2012
After careful reading of documentation seems to function xTaskSuspendAll( void );.
xTaskResumeAll( void );. has completly no influence. One thing from my site need to be clarify. I use in this project 2 UARTS one only receive frames and second one transmit data with new data (something like converter). Unfortunately I use for both UARTS interrupt, one receive interrupt and second one transmit interrupt. I saw that if I block one of them system work without any hung up. Due this one question appear what happen if 2 interrupt request come in same time and if this process is cause hung up. Both interrupt are on the same priority. Today I try remove transmit interrupt and do it in polling I hope this help. If anyone has an idea how to resolve this problem it will be great.

Thanks in advanced
KR VOLOVIQ

RE: FreeRTOSV7.1.0 on PIC18F25k80 Queue - Uart

Posted by Dave on February 15, 2012
vTaskSuspendScheduler() does not disable interrupts, if that is what you expect it to do. All it does is prevent anything causing a task switch. It definitely does that so does have an effect.

RE: FreeRTOSV7.1.0 on PIC18F25k80 Queue - Uart

Posted by Voloviq on February 18, 2012
Hello All,

I resolve all my problem and want to sharing my results.

Befor I strat rework my code I look on this forum similar threads and some I found. Tha main my problem was related with OERR bit of UART. I try to think why I have a problem with this bit. This bit is set when Uart receiver is in receive interrupt routine and come next byte and it's not possible to proper service it. The problem of this was very simple to low speed. When I perform my first experiency my PIC18F25K80 work with 16[MHz] main clock and UART work with 38400 Baudrate. I try to estimate how much time processor need to proper service push byte to queue and if become much data OERR bit was set. Resolution for this is very simple speed up microcontroller Main Clock and I do this. Increase speed from 16MHz to 64MHz resolve complete problem with OERR bit and hung up. That's all. In my opinion this thread may be colose due to find solution.

Thanks any one for help

Regards Voloviq


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner