#include void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog P2SEL|=0x00; // Port2 als input output benutzten P1DIR|=0xFF; // Port1 sind die 8 LEDs P2DIR|=0xFF; //Port2 sind die Latschsignale für 7-Segment decoder P3SEL |= 0x0a; // Assign I2C pins to module P3OUT |= 0x05; //am Port3 Pin 1+3 auf High setzen (Latch Pins) // P1OUT = 0x00; U0CTL |= I2C + SYNC; // Switch USART0 to I2C mode U0CTL &= ~I2CEN; // Recommended I2C init procedure I2CTCTL = I2CSSEL_2; // SMCLK I2CSCLH = 0x03; // High period of SCL I2CSCLL = 0x03; // Low period of SCL I2CNDAT = 0x01; // Transmit one byte I2CSA = 0x4c; // Slave address 1001100 U0CTL |= I2CEN; // Enable I2C, 7 bit addr, for (;;) { U0CTL |= MST; // Master I2CTCTL |= I2CSTT + I2CSTP; // Read, ST, SP (clears MST) while (I2CTCTL & I2CSTP); // Warten bis Stop Bit wieder gelöscht ist for(int i=0; i<20000; i++); unsigned int Zahl = I2CDRB; //Temperaturwert an Variable Übergeben unsigned int Zehner = Zahl/10; //Temperaturwert in Zehner und einer Ziffern unsigned int Einer = Zahl%10; //aufsplitten und an 7-segment decoder übergeben P2OUT = Zehner; P3OUT ^= 0x04; //Pin 1 am Port 3 wird zurückgesetzt P3OUT ^= 0x04; //Pin 1 am Port 3 wird gesetzt P2OUT = Einer; P3OUT ^= 0x01; //Pin 3 am Port 3 wird zurückgesetzt P3OUT ^= 0x01; //Pin 3 am Port 3 wird gesetzt } }