diff testavr.c @ 54:58f1ec46bff6

Add a beeper when the data is stale (only when USB is disabled as they share a pin) Move the time of day timer to OCR2 so we can use PB3/OC0 for PWM.
author darius@Inchoate
date Wed, 29 Oct 2008 17:41:04 +1030
parents 98b5a43fc748
children 09f8d879afb9
line wrap: on
line diff
--- a/testavr.c	Wed Oct 29 16:11:15 2008 +1030
+++ b/testavr.c	Wed Oct 29 17:41:04 2008 +1030
@@ -84,6 +84,10 @@
 #else
     DDRA = 0xff;
     PORTA = 0x00;
+
+    DDRB = 0x00;
+    PORTB = 0x00;
+
 #endif    
     /* GPIO (0:7) */
     DDRC = 0xff;
@@ -93,6 +97,20 @@
     DDRD = 0xf7;
     PORTD = 0xf7;
 
+#ifndef WITHUSB
+    /* Beep
+     *
+     * Fpwm = Fclk / (N * 510)
+     *      = 16e6 / (8 * 510)
+     *      = 3921Hz
+     *
+     * Behind ifndef because PB3 is A0 on PDI chip
+     *
+     * Phase correct PWM, non-inverted output, divide by 8 */
+    TCCR0 = _BV(WGM00) | _BV(WGM11) | _BV(COM00) | _BV(COM01) | _BV(CS01);
+    OCR0 = 253;
+#endif
+
     /* Set up the one wire stuff */
     OWInit();