Create simple alternating voltage by naively switching ports off and on.

This commit is contained in:
Marco 2022-05-27 02:21:58 +02:00
parent 15ff1cc339
commit 96ac9f1507

View File

@ -2,9 +2,10 @@
#include <util/delay.h> #include <util/delay.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include "include/uart.h" #include "uart.h"
#include "include/timer.h" #include "timer.h"
#include "include/commands.h" #include "commands.h"
#include "pins.h"
int main() int main()
{ {
@ -13,25 +14,45 @@ int main()
printf("Starting up!\r\n"); printf("Starting up!\r\n");
DDRB |= (1 << DDB2); DDRB |= (1<< DDB5);
DDRB |= (1 << DDB6);
DDRC |= (1 << DDC7); DDRC |= (1 << DDC6);
DDRD |= (1 << DDD0); DDRD |= (1 << DDD0);
DDRD |= (1 << DDD1); DDRD |= (1 << DDD1);
DDRD |= (1 << DDD6); DDRD |= (1 << DDD7);
unsetPin(&PORTC, PC6);
initCtcTimer0(); unsetPin(&PORTD, PD0);
unsetPin(&PORTD, PD1);
unsetPin(&PORTD, PD7);
sei(); // initCtcTimer0();
// sei();
while (1) { while (1) {
if ((PORTB & (1<<PB2))>1) { _delay_ms(10);
_delay_ms(5);
PORTB &= ~(1<<PB2); unsetPin(&PORTD, PD0);
} unsetPin(&PORTD, PD1);
_delay_us(1);
setPin(&PORTC, PC6);
setPin(&PORTD, PC7);
setPin(&PORTB, PB5);
_delay_ms(10);
unsetPin(&PORTC, PC6);
unsetPin(&PORTD, PC7);
unsetPin(&PORTB, PB5);
_delay_us(1);
setPin(&PORTD, PD0);
setPin(&PORTD, PD1);
} }
return 0; return 0;