[En-Nut-Discussion] samples at 8kHz

Harald Kipp harald.kipp at egnite.de
Thu Oct 14 17:15:57 CEST 2004


Christian,

Well, I think in the first place it should be noted,
that UDP isn't reliable. There will be no fixed "clock"
for incoming or outgoing packets. Thus some buffering is
required:

Ethernet -A-> InBuff -B-> DAC

Ethernet <-D- OutBuff <-C- ADC

The arrows may be viewed as tasks, reading from or writing
to buffers.

Tasks B and C must be strictly time controlled, best
using a native timer interrupt. Nut/OS uses timer 0 only.
For example, timer 1 can be used:

SIGNAL(SIG_OUTPUT_COMPARE1A)
{
     outb(TCNT1H, 0);
     outb(TCNT1L, 0);
     /* DAC or ADC work here */
}

/* Timer initialization, see ATmega128 datasheet. */
void InitTimer1(void)
{
     NutEnterCritical();

     outb(TCCR1A, 0);
     outb(TCCR1B, _BV(CS12));

     outb(TCNT1H, 0);
     outb(TCNT1L, 0);
     outb(OCR1AH, 0x01);
     outb(OCR1AL, 0x00);

     sbi(TIMSK, OCIE1A);
     NutExitCritical();
}

However, interrupt latency might be too high to maintain
ADC/DAC frequency. Thus, extra hardware may be required.

Tasks A and D are simple threads. Note, that it is impossible
to have UDP packets at exactly every 20 ms. Ethernet is non-
deterministic. Even switched Ethernets got some jitter, at least
caused by the CPU in the switching hardware.

Harald

At 16:55 14.10.2004 +0300, you wrote:
>Hello,
>
>I am not sure how to realize the following thing - a simple IP
>telephone. I have realized the Control Plane by adopting a simplified
>form of SIP (Session Initialization Protocol)
>
>But I come into troubles realizing the Media exchange.
>
>The phone should sample voice from ADC0 and makes out of it an RTP
>(Real Time Protocol) Stream (using G.711 encoding I have to send a UDP
>packet every 20ms). I have to get a sample every 125us (8kHz) and kick
>incoming RTP packets piece by piece to an PWM counter.
>
>My question now is: Can this be done using NUT/OS? What would be a way
>to do so?
>
>Cheers for any answers,
>
>Christian Wieser
>mailto:chwieser at ee.oulu.fi
>
>
>_______________________________________________
>En-Nut-Discussion mailing list
>En-Nut-Discussion at egnite.de
>http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion




More information about the En-Nut-Discussion mailing list