2

queueを使用して、UART ISR からバックグラウンド タスクに文字をバッファリングしようとしています。キューの長さを 512 バイトにしたい。unsigned portBASE_TYPEサイズ引数の型は xmega256a3 ではシングル バイト ( ) であるため、これは残念ながら不可能charです。キューの最大サイズが で変動する理由はありますportBASE_TYPEか? uint16_tではなく?

他の人が同じ制限に達したかどうか、またそれに対して何をしたか、興味があります。

4

2 に答える 2

4

Richard Barry (FreeRTOS 作成者) は、FreeRTOS メーリング リストに次の応答を投稿しました。

これは、8 ビット アーキテクチャの場合のみです。何度か言及されていますが (FreeRTOS サイトのサポート アーカイブを検索できます)、ほとんどの新しいプロジェクトが 32 ビット アーキテクチャを使用しているため、何年も言及されていません。簡単にできることは、portmacro.h の portBASE_TYPE の定義を変更することですが、コードが大きくなり、効率が低下します。

余談ですが、FreeRTOS デモの多くはキューを使用して割り込みとの間で文字をやり取りし、タスクと割り込みの通信の簡単な例を提供しますが、スループットが非常に低い場合 (コマンド コンソールなど) を除き、推奨されません。プロダクション コードの書き方。できれば DMA を使用した循環バッファを使用すると、はるかに効率的です。

于 2013-01-23T00:12:20.837 に答える
3

It's natural to use portBASE_TYPE for the majority of variables for efficiency reasons. The AVR is an 8 bit architecture and so will be more efficient dealing with 8 bit queue arithmetic than 16 bits. For some applications this efficiency may be critical.

Using a uint16_t doesn't make sense on 32 bit architectures and you'll note that the portBASE_TYPE for ARM cores is a 32 bit value, so choosing a uint16_t as the default type of queue length would be an artificial restriction on these cores.

Here's some options:

  • Refactor your tasks to read from the queue more often. Unless other tasks are stealing too much processing time, it should be possible to lower your ISR queue length and buffer the data in your reading thread.
  • Recompile FreeRTOS with a different portBASE_TYPE. I haven't tried this but I don't see a reason why this wouldn't work unless there was some assembler code in FreeRTOS which expected an 8 bit portBASE_TYPE. I had a quick look and didn't see any obvious signs of the assembler code expecting 8 bit types.
  • Use your own queuing library that has the capability to store as much data as you need. Use other FreeRTOS primitives such as a semaphore to signal to your task that data has been added to your queue. Instead of your task blocking on a queue read, it would block on a semaphore. Upon the semaphore being signalled, you'd use your own queuing library to read queued data.
于 2013-01-22T04:14:06.100 に答える