2010-07-07 09:45:45     How do you override interrupt priority in uCLinux?

Document created by Aaronwu Employee on Aug 22, 2013
Version 1Show Document
  • View in full screen mode

2010-07-07 09:45:45     How do you override interrupt priority in uCLinux?

Chris Schroeder (UNITED STATES)

Message: 91002   

 

First off, Let me explain the problem we’re having.  We are using a Blackfin 548 to process digital audio (Cobranet).  This audio has an external audio clock so we can sync other devices together and has a sampling frequency of 48kHz.  Every sampling period (20.83us) we get an interrupt that we are monitoring on an external GPIO pin set for on edge.  We are missing interrupts every now and then so when we start receiving them again, our audio channels are misaligned and we obviously have reduction in audio quality.  We are missing enough interrupts such that the SPORT FIFO is overflowing.

 

We’re also currently using uCLinux as our framework.

 

We believe the problem is related to interrupt priority, however, with uCLinux we’re having little success overriding the OS to give the audio priority.

 

Any ideas on how we can solve this issue?

 

We are also stuck in the process of getting Xenomai to work.  We turned to Xenomai in order to get RTOS capability (but keep uCLinux) so we can have more control over interrupts & timing.  We've followed the directions on this site to set it up, but it still isn't working.  The PREEMPT_RT patch doesn't work with uCLinux right now (from what I've read), so we can't use that option.

 

Thanks!

Chris Schroeder

Embedded Software Engineer

QuoteReplyEditDelete

 

 

2010-07-07 10:26:54     How do you override interrupt priority inuCLinux?

Michael Hennerich (GERMANY)

Message: 91005    Under:

 

->"BF548 Specific Configuration"

->"Interrupt Priority Assignment"

 

You can try to increase the IRQ priority of IRQ_PINTx.

By default they are set to the lowest priority in the system.

QuoteReplyEditDelete

 

 

2010-07-07 11:14:08     Re: How do you override interrupt priority inuCLinux?

Chris Schroeder (UNITED STATES)

Message: 91006   

 

That was the first thing we tried.  We've set this pin to the highest priority and still have this problem.  Our assumption is that the OS is running some other tasks that tie it up or disable interrupts during those tasks, which causes us to miss our interrupt.  Thanks.

 

I know this is a tough question.  We are essentially stuck in a situation that I've read many others have been in.  We need a hard-real time OS solution but stick with uCLinux (which isn't) for all it's app support.

QuoteReplyEditDelete

 

 

2010-07-07 14:32:35     Re: How do you override interrupt priority in uCLinux?

Mike Frysinger (UNITED STATES)

Message: 91009   

 

you didnt say what version of software you're using.  xenomai should work fine with every release we've made so far.

 

what other devices exactly do you have in your system that would be generating interrupts ?  presumably you have a network card on the async bank generating traffic, so try turning off the BFIN_INS_LOWOVERHEAD option in your kernel config.

QuoteReplyEditDelete

 

 

2010-07-08 00:35:19     Re: How do you override interrupt priority in uCLinux?

Sonic Zhang (CHINA)

Message: 91024   

 

What devices does this 48khz clock used to drive? If the accurate clock is so important to the devices, why not connect the hardware PIN directly other than via a kernel interrupt handler?

 

In addition, which release do you use? 2009R1 or SVN trunk?

QuoteReplyEditDelete

 

 

2010-07-08 03:46:08     Re: How do you override interrupt priority in uCLinux?

Wolfgang Muees (GERMANY)

Message: 91031   

 

Why do you get an Interrupt for each and every sample? This is not normally done for SPORT audio transmission. Instead, you are getting an Interrupt from the SPORT DMA controller if the buffer is filled. Even in a low-latency design, you should not try to get one interrupt per sample.

 

regards

 

Wolfgang

TranslateQuoteReplyEditDelete

 

 

2010-07-08 16:20:00     Re: How do you override interrupt priority in uCLinux?

Chris Schroeder (UNITED STATES)

Message: 91076   

 

Versions:  Xenomai v2.4.7 (whatever is bundled with 2009r1) & we just downloaded 2.5.3 (haven't tried it yet).  We are using 2008 version of uCLinux kernel (struggling to get 2009r1 to work).

 

What does BFIN_INS_LOWOVERHEAD do?

 

The Cobranet chip generates several digital audio clocks.  The 48kHz is the sampling frequency clock (I believe called frame sync) of the digital audio that we use to sync all the audio being fed to different ICs.  We are tying this hardware pin directly to a GPIO set as external interrupt.

 

Wolfgang: Can you elaborate? Is there a chance that we could still miss the interrupt generated by the SPORT DMA when the buffer is full?  or are you saying that this interrupt wouldn't be generated so frequently?

QuoteReplyEditDelete

 

 

2010-07-08 16:37:25     Re: How do you override interrupt priority in uCLinux?

Mike Frysinger (UNITED STATES)

Message: 91079   

 

the Kconfig text explains the option.  when you select it, just hit "?" to bring it up.  search with "/".

QuoteReplyEditDelete

 

 

2010-07-08 16:38:09     Re: How do you override interrupt priority in uCLinux?

Robin Getz (UNITED STATES)

Message: 91080   

 

Chris:

 

Upgrade - there are less problems in the 2009 release.

 

From: arch/blackfin/lib/ins.S

 

/*

* Reads on the Blackfin are speculative. In Blackfin terms, this means they

* can be interrupted at any time (even after they have been issued on to the

* external bus), and re-issued after the interrupt occurs.

*

* If a FIFO is sitting on the end of the read, it will see two reads,

* when the core only sees one. The FIFO receives the read which is cancelled,

* and not delivered to the core.

*

* To solve this, interrupts are turned off before reads occur to I/O space.

* There are 3 versions of all these functions

*  - turns interrupts off every read (higher overhead, but lower latency)

*  - turns interrupts off every loop (low overhead, but longer latency)

*  - DMA version, which do not suffer from this issue. DMA versions have

*      different name (prefixed by dma_ ), and are located in

*      ../kernel/bfin_dma_5xx.c

* Using the dma related functions are recommended for transfering large

* buffers in/out of FIFOs.

*/

 

 

BFIN_INS_LOWOVERHEAD controls which of the first two are used in the standard function.

 

-Robin

QuoteReplyEditDelete

 

 

2010-07-09 03:35:02     Re: How do you override interrupt priority inuCLinux?

Michael Hennerich (GERMANY)

Message: 91101    > Wolfgang: Can you elaborate?Is there a chance that we could still miss

> the interrupt generated by the SPORT DMA when the bufferis full? or are

> you saying that this interrupt wouldn't be generated so frequently?

 

When it comes to audio sampling - no one generates interrupts per sample.

For your 48kHz - you generate 48000 INTs/s. The system always have some interrupt latencies +

There are higher priority interrupts (CORE Timer) and some exceptions (Instruction and Data CPLB) going on.

 

Sampling all kind of throughput peripherals is always done using DMA.

Blackfin has a very flexible DMA controller. You typically sample a buffer of data and then generate an Interrupt once the buffer is full.

While the interrupt for the finished buffer is asserted the DMA can automatically start without any core intervention another DMA transfer.

So you have enough time to process the samples in buffer1 while buffer2 fills.

 

Take a look at descriptor based DMA in the Blackfin Hardware reference manual.

  docs.blackfin.uclinux.org/doku.php?id=dma_systems

 

If you have multiple devices - you can all sync them by using a common SPORT clock and connecting their Receive and Transmit -Frame Syncs accordingly.

 

This kind of throughput peripherals sampling is known to work even at much higher sample rates.

D1 PAL/NTSC Video for examples uses a sample clock if 27MHz...

 

-Michael

QuoteReplyEditDelete

 

 

2010-07-12 15:16:46     Re: How do you override interrupt priority inuCLinux?

Chris Schroeder (UNITED STATES)

Message: 91175   

 

Thanks for all your help.  I'll pursue the DMA route while another engineer tries to get Xenomai to work.  Regards, Chris

QuoteReplyEditDelete

 

 

2010-07-12 16:26:58     Re: How do you override interrupt priorityinuCLinux?

Michael Hennerich (GERMANY)

Message: 91176    DMA is the way to go here - I'm not familiar with your bridge chip - but it looks like something with an I2S interface.

So it could e trivial to recycle some of our ALSA SoC I2S framework drivers for it.

QuoteReplyEditDelete

 

 

2010-07-14 16:09:59     Re: How do you override interrupt priorityinuCLinux?

Chris Schroeder (UNITED STATES)

Message: 91253   

 

So, after reading the documentation (& some more about DMA), initially for testing purposes, is it possible to setup DMA on SPORT3 such that audio comes in on a DMA channel, gets put in a buffer & immediately dumped into another buffer that gets sent out a DMA channel on SPORT3?  I'll sample something like 100-1000 samples of 48kHz audio data at a time.

 

 

 

How should I setup the DMA?  1D register-based mode?  Should I enable an interrupt when it's full?  If so, when it's full, should I then copy that big block of memory over to another buffer, start the DMA transfer back out, and start another DMA transfer in?  Won't a memcpy be a waste of time & resources?  IE, i'm unsure how to get a rolling buffer setup.  How do I process the new transfered data while still receiving another buffer without first copying it somewhere so it doesn't get overwritten?  There is only 1 DMA chan for RX & TX.

 

This is all just for testing audio quality initially.  We will process the audio data & do something with it later.  For now, I just want to check that our 'missing samples' problem goes away.

Attachments

    Outcomes