Sound timer PWM fast mode

What is a Uzebox? How can I get one? Check here!
Post Reply
eric2800
Posts: 2
Joined: Wed Feb 28, 2018 2:58 am

Sound timer PWM fast mode

Post by eric2800 »

I have a question that has been nagging me for some time. I read the uzebox code and get most of the important bits. I just don't get the low level sound stuff. I have some experience with AVRs but have been away for months. So maybe you can correct my assumptions.

The timer 1 is set with no prescaler and takes 1820 cycles for complete ntsc line, visible + non-visible.
The timer 2 is fast pwm with no prescaler and goes to max (0xff) and rollsover . In that mode when timer hits compare reg the pin clears and sets again at timer=0. And the compare reg is set to the next value in the sound buffer every ntsc line. So I don't get the fact that the sound timer doesn't seem to be a ratio to the 1820 number. I thought I had searched most of the timer regs for setting or adjusting that changes the math but I certainly could have missed it.

Thanks,
Eric
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Sound timer PWM fast mode

Post by Jubatian »

That's correct, it isn't a ratio of 1820, and it works fine that way. Each sample is held for 7 - 8 PWM cycles: the sample is (normally) updated every 1820 cycles, and during that, 7 or 8 PWM cycles are started depending on how Timer 1 and Timer 2 align. This doesn't produce anything noticable in audio (a sample is either 62,7 us or 71,6 us long), however since PWM this way runs at 112KHz, it wouldn't even really need any filtering for smoothing (as this frequency is way above the human hearing range and the capabilities of speakers). I don't recall what the hardware actually has, just say that it would work even without filtering.
eric2800
Posts: 2
Joined: Wed Feb 28, 2018 2:58 am

Re: Sound timer PWM fast mode

Post by eric2800 »

Thanks for the response. I see now. I remember a thread where the "uze" himself stated that he tried a filter but didn't seem needed. I have been lurking for awhile. LOL. I tried to get something going for one of the challenges but didn't get around to it.

Eric
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Sound timer PWM fast mode

Post by Jubatian »

eric2800 wrote: Thu Mar 01, 2018 12:39 am(...) I tried to get something going for one of the challenges but didn't get around to it.
Do something about it, and vote for UCC-2018 in the Uzebox Code Challenge topic! There are many new video modes as well to start off from, and we could help you to get going if you have some good idea!
Post Reply