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




Loading

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
_CP0_BIC_STATUS(portALL)IPL_BITS);

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.

Regards.

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.

Eric


[ 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