I have a MSP430F5438A and i am trying to send nibbles to a 20x4 LCD screen with a Digole Serial Control Module on the bottom. I dont need to receive anything back from the LCD screen so the RX pin isnt hooked up. I am using the UART mode as for this project there are no i2c or SPI pins available. Any help would be great been searching and trying for ages and cant get anything!!! Code is below:
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P7SEL |= 0x03; // Port select XT1
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
__delay_cycles(100000); // Delay for Osc to stabilize
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
P9OUT |= BIT6; // power enable for led
P9DIR |= BIT6; // power enable for led
P4OUT = BIT4+BIT5; // P1.0/1 setup for LED output
P4DIR |= BIT4+BIT5; //
P3SEL |= BIT4+BIT5; // P3.4,5 UART option select
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x03; // 32k/9600 - 3.41
UCA0BR1 = 0x00; //
UCA0MCTL = 0x06; // Modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCTXIE + UCRXIE; // Enable USCI_A0 TX/RX interrupt
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/ interrupts enabled
__no_operation(); // For debugger
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA0IV,4))
{
case 0: break; // Vector 0 - no interrupt
case 2: break; // Vector 2 - RXIFG
case 4: // Vector 4 - TXIFG
__delay_cycles(5000); // Add small gap between TX'ed bytes
UCA0TXBUF = 0x08; // Transmit character
P4OUT ^= BIT4;
break;
default: break;
}
}