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] [April 2010 Threads] rtos viewerPosted by renaldtravispaad on April 30, 2010 Hi all, I am using freertos version 5.4.2 for a project in PIC24FJ256GB110. I used the following code to service the UART interrupt. void __attribute__((interrupt,no_auto_psv )) _U2RXInterrupt (void) { static portBASE_TYPE taskWoken; taskWoken=pdFALSE; IFS1bits.U2RXIF=0; c=U2RXREG; xQueueSendFromISR(uartqueue, &c, &taskWoken); }
The system seems to work fine for a few minutes and then fails. When I removed the source of the UART interrupt, the system worked alright. So, I changed the code as follows void __attribute__((interrupt,no_auto_psv )) _U2RXInterrupt (void) { static portBASE_TYPE taskWoken; taskWoken=pdFALSE; IFS1bits.U2RXIF=0; uartrecdval=U2RXREG; }
The system now worked with the UART interrupt well. I don't understand this behavior. Am I missing something here??. I would appreciate any help, so that I can understand what might be going on here.
I also see a plugin in MPLAB IDE called RTOS viewer. Can someone point me to some reading resources on this, so that I can get started on this.
Thanks in Advance!!!
RE: rtos viewerPosted by MEdwards on April 30, 2010 Is the priority of the interrupt set to portKERNEL_INTERRUPT_PRIORITY? If not try changing it to portKERNEL_INTERRUPT_PRIORITY to see if it fixes the problem. Also check the stack sizes of your tasks http://www.freertos.org/Stacks-and-stack-overflow-checking.html.
RE: rtos viewerPosted by Richard Damon on April 30, 2010 One possible issue I see is that you have declared your interrupt handler no_auto_psv, which means that the handler can not access the PSV segment. You then call xQueueSendFromISR which I am not sure if it needs the auto_psv segment. Most of the time the PSV segment will be setup right, and the interrupt will run fine. There may be a few small sections of your program in which the compiler needs to change the PSV segment, if the interrupt occurs there, and xQueueSendFromISR needs to access the PSV segment, then problems will occur.
A side note, your interrupt routine is not checking the taskWoken flag, so if a character does arrive, the waiting task will not start up right away, but will need to wait for the next time a task switch happens (like at the next timer tick) before it has a chance to process that character. This may be acceptable for your program.
RE: rtos viewerPosted by renaldtravispaad on April 30, 2010 Thanks edward and richard for replying...
@edward I have defined #define configKERNEL_INTERRUPT_PRIORITY0x01 in the freertosconfig.h file. Is it the same as portKERNEL_INTERRUPT_PRIORITY??
@richard The problem persisted even when I changed no_auto_psv to auto_psv. So, I am not sure if that was the mistake and yes it is okay for my task to start in the next tick
Also, I want to know if there is any material I can look up to use the RTOS viewer plugin in MPLAB.
Thanks in advance!!
RE: rtos viewerPosted by Richard Damon on April 30, 2010 If configKERNAL_INTERRUPT_PRIORIRY is set to 1, make sure you have changed the interrupt priority of the interrupt to be 1 also. (Interrupts with a priority high than that are not allowed to call FreeRTOS APIs).
As to the documentation of the View Plugin, I know it is in there, I just am not that familiar where. I believe you need to set the option to remove the static qualifications for FreeRTOS locals, enable some tracing options, and it is very helpful to make sure you give each queue a unique name.
RE: rtos viewerPosted by renaldtravispaad on May 6, 2010 hi richard, Apologies for a long delay. I got bogged down with another minor project.
I have another define in the freertosconfig.h which is #define configMAX_SYSCALL_INTERRUPT_PRIORITY0x04
My UART priority is 3. Do you still think I need to make the configKERNEL_INTERRUPT_PRIORITY as 3 or set the UART priority to 1?
Thanks!
RE: rtos viewerPosted by Richard on May 7, 2010 From the documentation page for the PIC24 port "Interrupt service routines that can cause a context switch must execute with priority portKERNEL_INTERRUPT_PRIORITY, and only call taskYIELD() at the very end of the service routine after the interrupt source has been cleared. See the file serial.c included in the demo application for an example."
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|