Part Number: MSP430F249
hello!
pls help a stupid student...
i am trying to get my msp430f249 work with uart,
it prints but dosent react to input(no eco)
i put a stop sign in the interrupt and its not triggering
cant understand why.
here is the code
thanks for the help!!!
#include <msp430.h>
#include <stdio.h>
#include "msp430f249.h"
void InitUART0 (void) //UART0 init
{
//input_data=P3IN; //Read only register
P3OUT = 0x00; // The outputs are low
P3SEL = 0x30; // Peripheral module function: enabled for UTXD0 and URXD0
P3DIR = 0x10; // 1 -> Output; 0 -> Input; UTXD0 output P3.4 TX
P3REN = 0x00; // Pullup/pulldown resistor disabled
UCA0CTL1 |= 0x01; // 1) Set UCSWRST
// 2) Initialize all USCI registers with UCSWRST = 1 (including UCAxCTL1)
UCA0CTL0 = 0x00; // 0x40 -> MSB first
UCA0CTL1 = 0x41;
UCA0BR1 = 0x00; // N = 32768/9600 = 3.413333
UCA0BR0 = 0x03; // Write integer portion of the divisor "N", i.e. UCBRx = INT(N) = 3
UCA0MCTL = 0x08; // UCBRSx = round( ( N - INT(N) ) * 8 ) = 4
UCA0CTL1 &= ~0x01;
// 5) Enable interrupts (optional)
IE2 |= 0x01; // USCI_A0 receive interrupt enable
IFG2 &= ~0x01; // Clear UCA0 RXIFG
__bis_SR_register(GIE);
// for (int i=10; i; i--); // short delay
}
void UART_transmit(unsigned char Data)
{
while(UCA0STAT & 0x01); // Check USCI busy flag
UCA0TXBUF = Data;
}
void UART0SendTxt(char* a)
{
for(;*a;++a) UART_transmit(*a);
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
UART_transmit (UCA0RXBUF+1); //transmit Echo + 1
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
InitUART0 ();
UART0SendTxt("\r\nhttps://www.olimex.com/");
UART0SendTxt("\r\nPress any key to return echo (next ASCII symbol)\r\n");
while (1);
}