Hello
I am new here, recently I working in Proteus using LPC2138 micro-controller
and make the programs in keil.
I connect virtual terminal with LPC2138 and i able to transmit string to
virtual terminal,
but i am not able to clean the virtual terminal.
Is any command in C program which clean the virtual terminal?
Here is code i c program:
#include <LPC213X.H>
#define in1 (1<<3)
#define in2 (1<<4)
#define in3 (1<<5)
#define in4 (1<<6)
void delay(unsigned int m)
{
T0MR0 = 3000*m;
T0MCR = 0x04;
T0TC = 0x00;
T0TCR = 0x01;
while(T0TC < T0MR0);
T0TC = 0x00;
}
void ser_tx(unsigned char ch) // transmiter
{
U0THR = ch;
while((U0LSR & (1<<5)) == 0);
}
char ser_rx() // receiver
{
unsigned char ch;
while((U0LSR & (1<<0)) == 0);
ch = U0RBR;
return(ch);
}
void ser_str(char *ch)
{
while(*ch != '\0')
{
ser_tx(*ch++);
}
}
int main()
{
//char buffer[100];
char ch;
IODIR0 = 0xff;
U0LCR = 0x83; // Enable DLAB and using 8-bit character lengh
PINSEL0 = 0x05; // assign the PINs RX and TX for UART0
U0DLM = (unsigned int)((3000000/(16*9600))/256); // calculate baud rate
for MSB
U0DLL = (unsigned int)((3000000/(16*9600))%256); // calculate baud rate
for LSB
U0LCR = 0x03; // Disable the DLAB, for protect the further changes to
these values
U0FCR = 0x07; // Enable and reset TX and RX FIFO
ser_str("1. First Motor Rotate\r");
ser_str("2. Second Motor Rotate\r");
ser_str("3. Both Motors Anti-rotation\r");
ser_str("4. Both Motors Stop\r");
ser_str("Enter your choice for motor rotation\r");
ser_str("Choice= ");
while(1)
{
ch = ser_rx();
ser_tx(ch);
switch(ch)
{
case '1':
IOSET0 = in1;
IOCLR0 = in2;
// delay(250);
break;
case '2':
IOSET0 = in3;
IOCLR0 = in4;
// delay(250);
break;
case '3':
IOSET0 = in2;
IOCLR0 = in1;
// delay(250);
IOSET0 = in4;
IOCLR0 = in3;
// delay(250);
break;
case '4':
IOCLR0 = in2;
IOCLR0 = in1;
// delay(250);
IOCLR0 = in4;
IOCLR0 = in3;
// delay(250);
break;
default:
ser_str("\rSorry! Your choice is wrong\r");
break;
}
}
}

