high frequency interrupt based sinewave generation AVR

Thread Starter

sadiq_bokhari

Joined May 8, 2015
11
Hi, i've written a code to generate a sinewave using the DAC of my Atmega128, we have been asked to use interrupts for this purpose, and minimum sample rate is 32, the frequency range being 5Hz - 5000Hz
for higher frequencies the interrupts become very frequent and sometimes the program does not take the input because of this or just gets stuck
what could i do to resolve this issue ?
 

nsaspook

Joined Aug 27, 2009
10,426
and instrument the code to see (with a scope) what's happening (with I/O toggles) when the code is being optimized for speed.

Loop-back testing main line code:
C:
        ringBufS_put(L.tx2b, 0b000000000);
        ringBufS_put(L.tx2b, 0b111111111);
        ringBufS_put(L.tx2b, 0b011111111);
        ringBufS_put(L.tx2b, 0b111111111);
        ringBufS_put(L.tx2b, 0b011111111);
        ringBufS_put(L.tx2b, 0b111111111);
        ringBufS_put(L.tx2b, 0b011111111);
        ringBufS_put(L.tx2b, 0b111111111);
        ringBufS_put(L.tx2b, 0b000000000);

        ringBufS_put(L.tx1b, 0b000000000);
        ringBufS_put(L.tx1b, 0b111111111);
        ringBufS_put(L.tx1b, 0b011111111);
        ringBufS_put(L.tx1b, 0b111111111);
        ringBufS_put(L.tx1b, 0b011111111);
        ringBufS_put(L.tx1b, 0b111111111);
        ringBufS_put(L.tx1b, 0b011111111);
        ringBufS_put(L.tx1b, 0b111111111);
        ringBufS_put(L.tx1b, 0b000000000);

        send_lcd_data('F');
        send_lcd_data('R');
        send_lcd_data('E');
        send_lcd_data('D');

        start_tx1();
        start_tx2();
        start_lcd();
        while (!ringBufS_empty(L.tx2b));
        while (!ringBufS_empty(spi_link.tx1b));
Top trace: logic high main cpu time, logic low in ISR cpu time showing transmit/receive interrupts.
bottom three: different ISR trigger toggles RS232 1&2 rx, SPI I/O burst and idle periods.


Detail in I/O bursts.
 
Last edited:
Top