stimmer / DueVGA

Arduino Due VGA library
92 stars 30 forks source link

Timers #4

Closed warpzon closed 11 years ago

warpzon commented 11 years ago

Hello Your library uses timer: TC1_IRQ, TC_0, channel 0(or 1). Can I change this to TC_1 or other timer? Is because "VGA" lib. conflicts with "Audio" lib.

stimmer commented 11 years ago

Yes, you can change the timer channel. However the VGA library is very aggressive with its interrupts and DMA so it might not work very well, you will just have to try it and see.

warpzon commented 11 years ago

Where can I change this? REG_TC0 change to REG_TC1? Thanks

stimmer commented 11 years ago

The changes involved are slightly confusing because the interrupt / peripheral hardware uses a different naming convention to the timer / counter hardware. So for example timer 2 channel 2 uses interrupt 8. The code currently uses timer 0 channel 1 and interrupt 1.

I have made a branch which changes this to timer 1 channel 1 and interrupt 4. Look here: https://github.com/stimmer/DueVGA/blob/TC1-1_TC4/VGA/VGA.cpp If this does not work for you, look at the diff to see which lines need to be changed: https://github.com/stimmer/DueVGA/commit/4fd9ab09ade7092192e90d8bbc1795ce99bb40c9#VGA/VGA.cpp

warpzon commented 11 years ago

Thanks you so much! It works with Audio lib. :+1:

stimmer commented 11 years ago

This fix has now been merged into the master branch.

himijendrix24 commented 9 years ago

I'm also trying to use Audio and Video Output. But when I stream a 44kHz/16 bit Wave and insert the VGA.beginn... command it already stutters, or even doesn't start the loop. Now I'm testing and trying various sample rates. I would like if somebody got good results with audio and video combined?

JerryI commented 9 years ago

Hi, himijendrix24! http://www.youtube.com/watch?v=E8qSB1Fm8WE - It uses Audio and Video output at the same time. But, native audio library doesn't work with VGA. You can use other method: http://pastebin.com/CQnHH5p8 (works with all sample rates) I used simply an audio buffer and one timer (https://github.com/ivanseidel/DueTimer).

himijendrix24 commented 9 years ago

Wow thank you Jerryl! This was my next Idea, to try doing it without the Audio library. I also noticed that with the Audio library the loop speed drops really much, even with lower sample rates.

I bet many people would find it quite useful, so you could share it to the Arduino Audio library forum if you like. Someone could easily use it to play two files parallel on each DAC, which isn't possible with the Audio Library.

himijendrix24 commented 9 years ago

I tried it and it works. It's much faster than the Audio library (with 44,1kHz, 16 bit Audio and VGA Colour mode it does ~150k (Empty) Loops per second).

But it doesn't work with the PAL/NTSC Mode, even when Audio with very low quality is used. Maybe because the PAL/NTSC requires more interrupt time...

The VGA Output is a true analog VGA Signal, right? Than I could just connect it to a SCART Input of a TV.... or is it a Digital signal (Like with newer Screens)? http://images.arianchen.de/soft15khz/vga-scart-35mm.png

JerryI commented 9 years ago

You can increase buffer size (#define SizeAudio 4096), it will add a little more speed. About PAL/NTSC, I don't know why It doesn't work. The VGA Output is a true analog VGA signal, but I really doubt that it will work good without any changes in VGA timings. I think, Stimmer can answer these questions.

himijendrix24 commented 9 years ago

I tried to connect a composite TV to the VGA Setup (using this http://www.geocities.ws/podernixie/htpc/vga2video.gif schematic) but of course it doesn't work, because of the timings, as you mentioned (PAL is in the MHz range I think and VGA around 15 kHz ?). Maybe the only way would be to buy a converter Box. First I try if I can get it running with the PAL mode.