Edited down source code: void InitisaliseUART ( void ) { UCA0CTL1 |= UCSWRST; UCA0CTL0 &= ~(UCPEN | UCPAR | UCMSB | UC7BIT |UCSPB | UCMODE_3 | UCSYNC); P3SEL |= (TXD_PIN + RXD_PIN); P1OUT &= ~RS485_RX_EN_PIN; P2OUT &= ~RS485_DRV_EN_PIN; UCA0CTL1 &= ~UCSWRST; IE2 |= (UCA0TXIE + UCA0RXIE); } void InitialiseI2C ( void ) { UCB0CTL1 = UCSWRST; UCB0CTL0 |= (UCMODE_3 | UCSYNC | UCMST); P3SEL |= (SDA_PIN + SCL_PIN); UCB0CTL1 |= UCSSEL_2; UCB0CTL1 &= ~UCSWRST; } #pragma vector = USCIAB0RX_VECTOR __interrupt void USCI_TX_ISR ( void ) { if (IFG2 & UCA0TXIFG) // If the Tx Buffer is Empty { // Pop a byte from the Tx Cyclic Buffer and bung it on UCA0TXBUF } else if (IFG2 & UCB0TXIFG) { P5OUT ^= LED3_PIN; } } #pragma vector = USCIAB0TX_VECTOR __interrupt void USCI_RX_ISR ( void ) { if (IFG2 & UCA0RXIFG) // If there is Byte in the Rx Buffer { // Read the byte on UCA0RXBUF and stick him in the Rx Cyclic Buffer } else if (IFG2 & UCB0RXIFG) { P5OUT ^= LED1_PIN; } }
↧