From: Nathaniel Wesley Filardo Date: Wed, 24 Mar 2010 04:21:31 +0000 (-0400) Subject: Add support for, and switch output to, OC2B PWMDAC X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=f99dc9f50338ec5aa7970504fd6f2cd1caeafac7;p=acmetensortoys-chiptunes Add support for, and switch output to, OC2B PWMDAC --- diff --git a/target/asm.S b/target/asm.S index 81459e2..505922f 100644 --- a/target/asm.S +++ b/target/asm.S @@ -43,6 +43,12 @@ __vector_14: out _SFR_IO_ADDR(TARGET_AUDIO_PORT), r24 ; 1 #endif + ; --------------------------------------------- + +#ifdef TARGET_AUDIO_PWM_OC2B + sts OCR2B, r24 ; 2 +#endif + ; --------------------------------------------- ; Run the noise shift register. ; 31 clocks. diff --git a/target/config.h b/target/config.h index 27b9d68..4b0dcf6 100644 --- a/target/config.h +++ b/target/config.h @@ -12,9 +12,15 @@ #endif -#define TARGET_AUDIO_PORT PORTC -#define TARGET_AUDIO_DDR DDRC -#define TARGET_AUDIO_PORT_SHIFT 2 +// #define TARGET_AUDIO_PORT PORTC +// #define TARGET_AUDIO_DDR DDRC +// #define TARGET_AUDIO_PORT_SHIFT 2 +#undef TARGET_AUDIO_PORT +#undef TARGET_AUDIO_DDR +#undef TARGET_AUDIO_PORT_SHIFT + +#define TARGET_AUDIO_PWM_OC2B + #define TARGET_LIGHT_PORT PORTB #define TARGET_LIGHT_DDR DDRB #define TARGET_LIGHT_ZERO 0x01 diff --git a/target/main.c b/target/main.c index 03f7719..67780e8 100644 --- a/target/main.c +++ b/target/main.c @@ -367,6 +367,13 @@ int main() { TIMSK0 = 0x02; +#ifdef TARGET_AUDIO_PWM_OC2B + TCCR2A = (1 << COM2B1) | (1 << WGM21) | (1 << WGM20); + TCCR2B = (1 << CS20); + OCR2B = 0; + DDRD |= (1 << 3); +#endif + asm("sei"); for(;;) { while(!timetoplay);