Hallo,
ich habe an einem Programm gearbeitet,
dass nach Ablauf eines Timers eine LED anschalten soll.
Ich arbeite mit Notepad++ als Compiler kommt AVR Toolchain zum einsatz.
Das ganze läuft auf einem AtXMega128a3u mit einer Frequenz von 24MHz und Prescaler 1024.
Nach 1 Sekunde soll der Interrupt ausgeführt werden und eine LED einschalten.
Mein Code:
Danke im VorrausCode:void humidity_timer_init(){ pmic_init(); sysclk_init(); volatile void *tc = &HUMIDITY_TIMER; //Adress tc_enable(tc); //Enable timer/counter tc_write_period(tc, 100); //This will specify the TOP value of the counter. The timer will overflow and reset when this value is reached. tc_set_overflow_interrupt_callback(tc, LED_tester); //Set the callback function for overflow interrupt tc_set_overflow_interrupt_level(tc, TC_INT_LVL_HI ); //Set the overflow interrupt level tc_write_clock_source(tc, HUMIDITY_COUNTER_CLKSEL ); //Set the clock source } void LED_tester(){ ioport_set_pin_dir(D2, IOPORT_DIR_OUTPUT); ioport_set_pin_level(D2, true); ioport_toggle_pin_level(D2); //Turn LED D2 On }
MfG
Julian







Zitieren


Lesezeichen