Sfoglia il codice sorgente

Fixed timer's counters.

Vladimir N. Shilov 4 anni fa
parent
commit
ad9dba7ff1
4 ha cambiato i file con 19 aggiunte e 6 eliminazioni
  1. 1 0
      IN4x6-dev
  2. 1 1
      flash.cmd
  3. 1 1
      inc/rtos.h
  4. 16 4
      src/main.c

+ 1 - 0
IN4x6-dev

@@ -0,0 +1 @@
+branch

+ 1 - 1
flash.cmd

@@ -3,5 +3,5 @@
 SET AVRDUDE=D:\Program\avrdude\avrdude.exe -C D:\Program\avrdude\avrdude.conf
 SET MCU=m8
 
-%AVRDUDE% -p %MCU% -c usbasp -U flash:w:build\snc.hex:a
+%AVRDUDE% -e -u -y -p %MCU% -c usbasp -U flash:w:build\snc.hex:a
 rem -U eeprom:w:build\snc.eep:a

+ 1 - 1
inc/rtos.h

@@ -28,7 +28,7 @@
  */
 #define TIMER_HZ		    1000
 #define TIMER_PRESCALER 64
-#define	TIMER_CNT		    (0x100 - (F_CPU / TIMER_PRESCALER / TIMER_HZ))
+#define	TIMER_CNT		    ((0x100 - (F_CPU / TIMER_PRESCALER / TIMER_HZ)) / 2)
 
 #define TIMER_TCCR		  TCCR0
 #define TIMER_TCNT		  TCNT0

+ 16 - 4
src/main.c

@@ -22,11 +22,21 @@
 #include "common.h"
 
 /* Defines */
-/* Timer2 settings */
-#define TIMER2_HZ         600
+/* Timer2 settings
+ * Prescaler (CS22/CS21/CS20 - value):
+ * 0/0/0 - stop
+ * 0/0/0 - 1 (no prescale)
+ * 0/1/0 - 8
+ * 0/1/1 - 32
+ * 1/0/0 - 64
+ * 1/0/1 - 128
+ * 1/1/0 - 256
+ * 1/1/1 - 1024
+ */
+#define TIMER2_HZ         360
 #if F_CPU == 16000000
   #define TIMER2_PRESCALER  256
-  #define TIMER2_CS         (1<<CS22 | 0<<CS21 | 0<<CS20)
+  #define TIMER2_CS         (1<<CS22 | 1<<CS21 | 0<<CS20)
 #elif F_CPU == 8000000
   #define TIMER2_PRESCALER  64
   #define TIMER2_CS         (0<<CS22 | 1<<CS21 | 1<<CS20)
@@ -55,7 +65,9 @@
 #define FULL_BRIGHT_OFF   0x22
 static const uint8_t PROGMEM brightConv[BRIGHT_IDX_MAX+1] = {
 #if F_CPU == 16000000
-  155, 164, 181, 211, 255
+  /* 155, 164, 181, 211, 255 */
+  /* for 83: */
+  117, 151, 185, 219, 255
 #elif F_CPU == 8000000
 	54, 71, 106, 165, 255
 #endif // F_CPU