summaryrefslogtreecommitdiff
path: root/picl-firmware/fan_control.c
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2020-03-31 16:05:29 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2020-03-31 16:05:29 +0200
commitd50d2a22f0252f564fdbc0a58cbb9041f67ba357 (patch)
tree714a1d86faa516199f6e2d6d60a566649e3bcaeb /picl-firmware/fan_control.c
parent7e31ec13074d27c6173c89a9d12e9e4be51f9da8 (diff)
downloadPiCl-d50d2a22f0252f564fdbc0a58cbb9041f67ba357.tar.gz
PiCl-d50d2a22f0252f564fdbc0a58cbb9041f67ba357.tar.bz2
PiCl-d50d2a22f0252f564fdbc0a58cbb9041f67ba357.zip
Tries to trace the OCOA and OCOB pins but no output?HEADmaster
Diffstat (limited to 'picl-firmware/fan_control.c')
-rw-r--r--picl-firmware/fan_control.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/picl-firmware/fan_control.c b/picl-firmware/fan_control.c
index 6b0bd99..3cebd7e 100644
--- a/picl-firmware/fan_control.c
+++ b/picl-firmware/fan_control.c
@@ -2,6 +2,18 @@
#include <avr/interrupt.h>
#include <avr/sleep.h>
+#include <avr/avr_mcu_section.h>
+
+AVR_MCU(8000000, "attiny24");
+AVR_MCU_VOLTAGES(5000, 5000, 5000);
+
+const struct avr_mmcu_vcd_trace_t my_trace[] _MMCU_ = {
+ { AVR_MCU_VCD_SYMBOL("PORTA"), .what = (void*)&PORTA },
+ { AVR_MCU_VCD_SYMBOL("PORTB"), .what = (void*)&PORTB },
+ { AVR_MCU_VCD_SYMBOL("PINA"), .what = (void*)&PINA },
+ { AVR_MCU_VCD_SYMBOL("PINB"), .what = (void*)&PINB }
+};
+
void setup_clock() {
CLKPR |= (1UL << CLKPCE); //enable setting of prescaler.
CLKPR &= ~(15 << CLKPS0); //set prescaler to 1, system clock 8MHz.
@@ -20,11 +32,11 @@ void setup_adc() {
}
void setup_timers() {
- //Set channel A to inverted mode
+ //Set channel A to non inverted mode
TCCR0A &= ~(3UL << COM0A0);
TCCR0A |= (2UL << COM0A0);
- //Set channel B to inverted mode
+ //Set channel B to non inverted mode
TCCR0A &= ~(3UL << COM0B0);
TCCR0A |= (2UL << COM0B0);
@@ -40,8 +52,8 @@ void setup_timers() {
TCCR0B &= ~(7UL << CS00);
TCCR0B |= (1UL << CS00);
- DDRA |= (1UL << PA7);
- DDRB |= (1UL << PB2);
+ DDRA |= (1UL << DDA7);
+ DDRB |= (1UL << DDB2);
}
void enable_ADC() {
@@ -96,9 +108,11 @@ ISR(ADC_vect) {
}
}
-volatile int b = 0;
+AVR_MCU_SIMAVR_COMMAND (& GPIOR0 ) ;
int main() {
+ GPIOR0 = SIMAVR_CMD_VCD_START_TRACE;
+
setup_clock();
setup_adc();
setup_timers();
@@ -106,8 +120,12 @@ int main() {
OCR0A = 0x80;
OCR0B = 0xB0;
- while(1) {
+ //run for however long this takes...
+ uint16_t t = 0xffff;
+ while (t > 0) {
+ t--;
+ }
- b+=1;
- }
+ GPIOR0 = SIMAVR_CMD_VCD_STOP_TRACE;
}
+