Using embedded proggraming, Code Composer Studio 6.0.1,
Trying to configurate UART to communicate between MSP430F6736A and my PC. Using USB/RS485 converver(2 vire (A,B)).
For sending data using HERCULES(app for testing communication).
#include <msp430.h>
#include <msp430f6736.h>
/*
* main.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P4DIR |= BIT6;
P4OUT &= ~BIT6;
//clock
//UCSCTL0 |= DCO_0 | MOD_0;
//UCSCTL1 |= DCORSEL_0;
// Config pinov P2.2 a P2.3 na ich funkciu(Rx a Tx)
P2SEL |= BIT2 + BIT3; // RX and TX pins
// config comm
UCA1CTLW0 |= UCSWRST; // reset UCA1 for config
UCA1CTLW0 |= UCSSEL_1 ; // ACLK as source clock
UCA1MCTLW |= UCBRS0;
// Baudrate from datasheet
UCA1BR0 = 1; // 1200 Baud
UCA1BR1 = 11; // 1200 Baud
UCA1CTLW0 &= ~UCSWRST; // UCA1 back from reset
// interrupts enabled for RT and TX
UCA1IE |= UCTXIE | UCTXIE;
__bis_SR_register(GIE); // global interupt enabled
}
#pragma vector=USCI_A1_VECTOR
__interrupt void Recieve_ISR(void)
{
while (!UCA1IFG) // USCI_A0 TX buffer ready?
{
P4DIR |= BIT6;
P4OUT &= ~BIT6;
UCA1RXBUF = UCA1TXBUF; // TX -&gt; RXed character
}
}
All I want is when I send data(for eample number 5) from HERCULES(config same: 1200 baud, no parity, 1 stop bit) I want to receive them and turn LED on. But it doesn´t work.
Somewhere in this code is something missing or something bad written. , . I got big head from datasheets so can anyone help me?