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

Interrupts being disabled

Posted by seanbzd on August 7, 2015

Hi, I'm working on the FreeRTOS port on the zynq platform. I am doing some SPI transfers in the ISR handler and once every few minutes, i'm getting errors during the SPI transfers (RX Buffer overrun and Tx Buffer underrun). I believe these errors are a result of interrupts being disabled. We have several tasks, but if I disable a particular task(happens to be the highest priority task on our system), I do not see the SPI transfer errors. So, I'm thinking that something this task is doing is causing the interrupts being disabled that is affecting the SPI transfers. Question is what APIs should I be looking for that could potentially be disabling interrupts. I searched for taskENTERCRITICALSECTION but we are not using it. Can you point me to other calls that could be disabling interrupts. I see that the xSemaphoreTake() and xSemaphoreGive() would also disable interrupts but I suppose it is done so very briefly that it should not affect the SPI transfers.

Thanks for your help.


Interrupts being disabled

Posted by heinbali01 on August 7, 2015

Hi Sean,

I'm afraid that you don't provide enough information to give a satisfying answer.

At what speed do you run SPI? Is it a byte-by-byte transfer or do you use DMA? Is your Zynq the SPI Master? ( making a CPU a SPI slave is always very problematic )

Who is delivering the data for the SPI, is that a regular task? Does that task get enough attention from the CPU when your high-priority task is running? Do the TX buffers get filled on time? Do the RX buffers get flushed on time? Are RX buffers available when a burst of data comes in?

When interrupts are disabled in the FreeRTOS kernel, it happens indeed very briefly.

The Zynq is a very fast CPU, I suppose you have it running at 666 Mhz? Or less?

Are you sending a lot of SPI data? If you are sending KB's of data, I would definitely consider using DMA channels.

Regards.


Interrupts being disabled

Posted by lciummo on August 7, 2015

Sean. I had similar problem with SPI. See code below for example of disabling ints...

// Clear tranfer count register
// SPI0_TCR = 0;
int spi_cnt;

taskENTER_CRITICAL();
taskDISABLE_INTERRUPTS();

for (spi_cnt = 0; spi_cnt < BYTES_TO_READ; spi_cnt++) {
	SPI0_PUSHR = (command | SPI_PUSHR_CONT_MASK | SPI_PUSHR_PCS(1)
			| SPI_PUSHR_CTAS(0));
	//while (!(SPI0_SR & SPI_SR_TFFF_MASK)  );

	command = spi_cnt + 1;
	while (!(SPI0_SR & SPI_SR_RFDF_MASK))
		;
	unsigned char byte;
	encoder[spi_cnt] = SPI0_POPR;
	SPI0_SR = SPI_SR_RFDF_MASK; // clear the reception flag (not self-clearing)

	//printf("byte read %0x\n",SPI0_POPR );
}
// Last byte transfer/receiver
command = 0xff;
SPI0_PUSHR = (command | /* SPI_PUSHR_CONT_MASK | */SPI_PUSHR_PCS(1)
		| SPI_PUSHR_CTAS(0));
while (!(SPI0_SR & SPI_SR_TFFF_MASK))
	;  // wait for transmit

while (!(SPI0_SR & SPI_SR_RFDF_MASK))
	;

unsigned char junk = SPI0_POPR;
taskEXIT_CRITICAL();
taskENABLE_INTERRUPTS();
SPI0_SR = SPI_SR_RFDF_MASK;  // clear the reception flag (not self-clearing)

unsigned long int encRaw = 0;
for (int k = 5; k > 1; k--) {  //5,4,3,2
	encRaw = (encRaw << 8) + encoder[k];
}
ifdef ENDAT22
encRaw = encRaw >> 1;
endif

Interrupts being disabled

Posted by e-christenson on August 8, 2015

Wait a minute...I don't particularly know the Zynq CPU... but if it is running at multiple hundred MHz speeds, I expect it has multiple priority levels within the CPU, and, at least on the port I am familiar with, CPU priority levels and RTOS priority levels are different animals, so we need to be extremely careful about that.

On the Microchip dsPIC30F architecture, all of the tasks run at CPU priority zero, the freeRTOS kernel runs at CPU priority 1, and there are additional, higher CPU priorities available for interrupts such as the SPI handler.

I also suggest you AUDIT the source code for the meanings of the critical section and disable interrupts primitives...you will need to know exactly what those do in your architecture. On the pic, both of those simply raise the current CPU priority level to that of the RTOS priority.

Hope this helps!


[ 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