]> hydra-www.ietfng.org Git - acmetensortoys-chiptunes/commitdiff
Add support for, and switch output to, OC2B PWMDAC
authorNathaniel Wesley Filardo <nwf@smaug.priv.ietfng.org>
Wed, 24 Mar 2010 04:21:31 +0000 (00:21 -0400)
committerNathaniel Wesley Filardo <nwf@smaug.priv.ietfng.org>
Wed, 24 Mar 2010 04:21:31 +0000 (00:21 -0400)
target/asm.S
target/config.h
target/main.c

index 81459e229a81569df1241e02e6d19843a9742c36..505922f8000619808eee8a0920f1addb81c1c9f0 100644 (file)
@@ -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.
index 27b9d682caf4a9058677d6baf789cc97a7f1526a..4b0dcf63796091d97b469d5878cc7a26b32ff3aa 100644 (file)
 
 #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
index 03f7719f13ac3619251362de7d757a9ac4d1827b..67780e8246691f4b19ec672112716a90525b417f 100644 (file)
@@ -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);