hi all,
I am working on sending data to MSP430FG4618 via serial port & display it on LCD. The data is transmitted & received in character format. After receiving the character i convert it into integer & when i use LCDMEM function to display it all the segments(a-h) of that LCDMEM are on. Can anyone tell me along with the character transmitted what is send to mark the end of string. How can i separate it from the data. Here is the code:
#include “msp430xG46x.h”
#include “LCD.h”
void main(void)
{
int i;
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Configure load caps
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i–); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
// on experimenter’s board P2.4 is UCA0TXD and P2.5 is UCA0RXD
P2SEL |= 0x030; // P2.5,4 = USCI_A0 RXD/TXD
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x03; // 32k/9600 - 3.41
UCA0BR1 = 0x00;
UCA0MCTL = 0x06; // Modulation
UCA0CTL1 &= ~UCSWRST; // Initialize USCI state machine
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
_BIS_SR(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIA0RX_ISR (void)
{
const int charseg=
{
LCD_A+LCD_B+LCD_C+LCD_D+LCD_E+LCD_F, // ‘0’
LCD_B+LCD_C, // ‘1’
LCD_A+LCD_B+LCD_D+LCD_E+LCD_G, // ‘2’
LCD_A+LCD_B+LCD_C+LCD_D+LCD_G, // ‘3’
LCD_B+LCD_C+LCD_F+LCD_G, // ‘4’
LCD_A+LCD_C+LCD_D+LCD_F+LCD_G, // ‘5’
LCD_A+LCD_C+LCD_D+LCD_E+LCD_F+LCD_G, // ‘6’
LCD_A+LCD_B+LCD_C, // ‘7’
LCD_A+LCD_B+LCD_C+LCD_D+LCD_E+LCD_F+LCD_G, // ‘8’
LCD_A+LCD_B+LCD_C+LCD_F+LCD_G // ‘9’
};
char x,z;
int y,i;
P5SEL = 0x1C; // P5.2/3/4 = LCD COM lines
for (i = 19; i > 0; i–) LCDMEM = 0; // Clear LCD
LCDACTL = LCDON + LCD4MUX + LCDFREQ_128; // 4mux LCD, ACLK/128
LCDAPCTL0 = 0x7E;
x=UCA0RXBUF-0x30;
y=(int)x;
LCDMEM[4]=charseg[y];
}