NorthGuy
Well-Known Member
It is unlikely that you can get anywhere close to maximum efficiency with a C program.
I'm not familir with AVR (some processers have weired limitations, you never know). A clever assembler program on PIC could run at about 2.2 CPU cycles per channel per interrupt. This is about 30 cycles per interrupt (counting in interrupt overhead). PIC runs 2(or 4) times slower than the clock (don't know about AVR) so at 20MHz clock assumin 1/2 factor, it would be, 100 ns per cycle. AVR should be similar, but you need to look at the AVR datasheet to figure out the real speed. If 100 ns is correct, you should be able to get (100 ns x 3) 3us per interrupt. Leaving half of the bandwidth to USB (should be enough), you get 6us per interrupt or 167kHz. You need 379 ticks to get 439.8 Hz, and 380 ticks to get 438.6 Hz. I cannot tell if that's a good resolution for you.
At any rate, 40MIPS PIC @ $6 would be enough.
To let it work all together, you need to make timer interrupt high priority and run USB in the main thread with low priority interrupts. This way they will live together without interference.
Keep in mind that you get a square wave, which will not sound anywhere as good as a sine wave.
I'm not familir with AVR (some processers have weired limitations, you never know). A clever assembler program on PIC could run at about 2.2 CPU cycles per channel per interrupt. This is about 30 cycles per interrupt (counting in interrupt overhead). PIC runs 2(or 4) times slower than the clock (don't know about AVR) so at 20MHz clock assumin 1/2 factor, it would be, 100 ns per cycle. AVR should be similar, but you need to look at the AVR datasheet to figure out the real speed. If 100 ns is correct, you should be able to get (100 ns x 3) 3us per interrupt. Leaving half of the bandwidth to USB (should be enough), you get 6us per interrupt or 167kHz. You need 379 ticks to get 439.8 Hz, and 380 ticks to get 438.6 Hz. I cannot tell if that's a good resolution for you.
At any rate, 40MIPS PIC @ $6 would be enough.
To let it work all together, you need to make timer interrupt high priority and run USB in the main thread with low priority interrupts. This way they will live together without interference.
Keep in mind that you get a square wave, which will not sound anywhere as good as a sine wave.