From d50d2a22f0252f564fdbc0a58cbb9041f67ba357 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Tue, 31 Mar 2020 16:05:29 +0200 Subject: Tries to trace the OCOA and OCOB pins but no output? --- picl-firmware/fan_control.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'picl-firmware/fan_control.c') 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 #include +#include + +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; } + -- cgit v1.2.3-70-g09d2