So sieht er jetzt aus:
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include <stdlib.h>
#include <string.h>
#include "uart.h"
#include "owi.h"
#define UART_BAUD_RATE 9600
ISR(PCINT_vect)
{
//EIFR |= (1<<PCIF); //<--hat auch nicht geklappt
uart_puts("A pin change interrupt occurred!");
}
int main(void)
{
DDRB = 0x00; //set pins as output
PORTB |= (1<<PB0) | (1<<PB1); //activate pullup
PCMSK |= (1<<PCINT0) | (1<<PCINT1); //mask port
GIMSK |= (1<<PCIE); //activate PCinterrupts
EIFR |= (1<<PCIF); //clear interrupt flag
uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
sei();
signed int temperatur;
char s[20];
char temp[5];
while(1)
{
OWReset();
OWWriteByte(0xcc); //skip rom
OWWriteByte(0x44); //convert T
_delay_ms(500);
OWReset();
OWWriteByte(0xcc);
OWWriteByte(0xbe);
temperatur = OWReadByte();
temperatur |= (OWReadByte() << 8);
temperatur = temperatur / 2;
strcpy(s,"$PMBPS,");
itoa(temperatur,temp,10);
strcat(s,temp);
uart_puts(s);
uart_puts("\r\n");
_delay_ms(500);
}
return 0;
}
Lesezeichen