Respected All,
Iam a student and doing a project using MSP430G2553 micro controller, in one part of my project i want to establish serial communication between MSP430 and hyper terminal of my computer using RS485 electrical connection.
for RS485 iam using Texas trans receiver IC sn65HVD10(8 pin device).
There is a part in my program where as soon as i send some character through hyper terminal to MSP430,my MSP430 should respond the data already saved in an array .(same as in example code on TI website after receiving character "u" it is sending hello world)
The problem is my controller is able to receive the character which iam sending from hyper terminal ,and after receiving my controller will send some data, but data transmitted by micro controller is not getting displayed at hyper terminal.
(Basic loop back program is also not working....my RXBUF is getting data from hyper terminal but TXBUF data cannot be displayed in hyper terminal)
Since this transceiver is half duplex i need to control the direction, for that pin 2 and 3 of trans receiver are tied together and i connected them to port 2.0 of micro controller (P2.0out = 0 when in receiver mode and p2.0out = 1 when in transmitting mode,iam doing this through software).
The part of code is as follow:-
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0x00; // All P1.x reset
P1SEL = 0x06; // P1.1 = RXD, P1.2=TXD
P1SEL2 = 0x06 ; // P1.1 = RXD, P1.2=TXD
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
UCA0CTL1 |= UCSSEL_2; // CLK = SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE ;//+ UCA0TXIE; // Enable USART0 RX/TX interrupt
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/ int until Byte RXed
}
// UART0 TX ISR
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR (void)
{
//if (i <= count+9)
UCA0TXBUF = tx[i++];
//else
if (i >= count+9)
IE2 &= ~UCA0TXIE; // Disable USCI_A0 TX interrupt
}
// UART0 RX ISR
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR (void)
{
if (UCA0RXBUF == 'a')
{
P2OUT = 0x01; //Transmit enable
i = 0;
IE2 |= UCA0TXIE;
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = tx[i++];
}
}
iam working on IAR workbench and through that only i telling that my TXBUF and RXBUF are working fine after checking register's.
iam also using RS485 to RS232 converter (is there is problem with this? but it is working fine when iam sending data from hyperterminal.....)to connect through my PC.
Any suggestion are welcome......
Regards
Rahul