#include #include // für Zeichen (Infotext) notwendig #include // für sprint #include unsigned int t,k; void UART1_senden_einstellen(void); void E32_konfigurieren(void); void konfiguration_senden(void); char i,txbuffer[6]; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer UART1_senden_einstellen(); P2DIR |= BIT4 + BIT5; // M0 = 2.4, M1=2.5 P2OUT |= BIT4 + BIT5; // M0 und M1 = H E32 konfigurieren _EINT(); // allg. Interrupt-Freigabe for(;;); } void UART1_senden_einstellen(void) { P3SEL |= 0xC0; // P3.6 = USART1 TXD ; P3.7 = RXD1 ME2 |= UTXE1; // Enable USART1 TXD/RXD UCTL1 |= CHAR; // 8-bit character UTCTL1 |= SSEL0; // UCLK = ACLK UBR01 = 0x03; // 32k/9600 - 3.41 UBR11 = 0x00; // UMCTL1 = 0x4A; // Modulation UCTL1 &= ~SWRST; // Initialize USART state machine IE2 |= UTXIE1; // Enable USART1 RX interrupt // _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt } void E32_konfigurieren(void) { txbuffer[0] = 0xC0; // sichert die Parameter nach Stromausfall txbuffer[1] = 0x44; // Adresse oberes Byte (Gerät 3, DS10) txbuffer[2] = 0x44; // Adresse unteres Byte (Gerät 3, DS10) txbuffer[3] = 0x1A; // 8N1, UART baut rate:9600 (bps), Übertragungsrate:2,4k (bps) txbuffer[4] = 0x07; // Kanal 7 txbuffer[5] = 0xC7; // "fixed" Übetragungsmodus; TXD und AUX als Ausgang RXD als Eingang; 1100 0111 = 0xC7 } void konfiguration_senden(void) { i=0; while (i<6) { TXBUF1 = txbuffer[i]; while (!(IFG2 & UTXIFG1)); // USART1 TX buffer ready? i++; } } interrupt (UART1TX_VECTOR)UART1 (void) { }