Quality RTOS & Embedded Software

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


PIC32 CP0 operations

Posted by Eric Lofstad on February 15, 2010
The code for the PIC32 in portmacro.h does a read-modify-write on CP0 to control stuff like interrupts, which does not seem safe. For example this code enables interrupts.
ulStatus = _CP0_GET_STATUS()
ulStatus &= ~portALL_IPL_BITS;
_CP0_SET_STATUS( ulStatus );
why do that rather than this

RE: PIC32 CP0 operations

Posted by Richard on February 16, 2010
The code generated by your suggestion is:

9D000020 40026000 mfc0 v0,Status << read
9D000024 00401821 addu v1,v0,zero
9D000028 3C02FFFF lui v0,0xffff
9D00002C 344203FF ori v0,v0,0x3ff
9D000030 00621024 and v0,v1,v0
9D000034 40826000 mtc0 v0,Status << write

so it is still performing a read/modify/write sequence so I'm not sure what is to be gained.

That said, the original code is probably less than ideal, however I don't think it is problematic because each task has its own Status value, and its own stack onto which ulStatus is stored.


RE: PIC32 CP0 operations

Posted by Eric Lofstad on February 16, 2010
Thanks for the reply, I should have looked at the assembly first.
I'm still left wondering how atomic the operation is, but the is independent of FreeRTOS.


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

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

Latest News

Meet us at Embedded World. Hall 3A-525.

Hear from Richard Barry at Embedded World. Feb 28, 16:00, Hall 4-428.

Video: Watch James Gosling & Richard Barry at re:Invent, Las Vegas 2017.

FreeRTOS kernel V10.0.1 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