godatguitar
New Member
HI All
I am very new(ish) to 8051's as I have completed some basic work with them in assembler and c, but I am stuck on something now...
I need to receive some data from the serial port on the 8051. I would prefer to write in C if possible.
I want to receive some x and y integer (coordinates) from the serial and then move motors to those coordinates. Moving the motors is relatively simple.
Basically, I do not know if I have to do it character at a time then put them into two seperate variables, like xcoord, ycoord for example.
main()
{
SCON = 0x50; /* mode 1, 8-bit uart, enable receiver */
TMOD = 0x20; /* timer 1, mode 2, 8-bit reload */
TH1 = 0xFE; /* reload value for 2400 baud */
ET0 = 0;
TR1 = 1; /* start the timer */
TI = 1; /* clear the buffer */
ES = 1; /* allow serial interrupts */
EA = 1; /* enable interrupts */
P1 = 0; //This is the port for the motors.
while (1==1)
{
int i;
int j;
for(i=0; i<xcoord;i++)
P1 = .......;
for(j=0;j<ycoord;j++)
P1 = .......;
P1 = 0;
P2 = 0;
TI = 1; //then transmit a complete signal out of serial
}
The code above shows bits of what i have so far (in C). Basically it should set up the 8051 properly.
Does anyone have any ideas how to read in 2 integers, say 0 to 350, and a end-of-transmission char?
Please post. or email me at:
godatguitar@hotmail.com
Please forgive me if this is totally wrong etc, I am new and learning....
I am very new(ish) to 8051's as I have completed some basic work with them in assembler and c, but I am stuck on something now...
I need to receive some data from the serial port on the 8051. I would prefer to write in C if possible.
I want to receive some x and y integer (coordinates) from the serial and then move motors to those coordinates. Moving the motors is relatively simple.
Basically, I do not know if I have to do it character at a time then put them into two seperate variables, like xcoord, ycoord for example.
main()
{
SCON = 0x50; /* mode 1, 8-bit uart, enable receiver */
TMOD = 0x20; /* timer 1, mode 2, 8-bit reload */
TH1 = 0xFE; /* reload value for 2400 baud */
ET0 = 0;
TR1 = 1; /* start the timer */
TI = 1; /* clear the buffer */
ES = 1; /* allow serial interrupts */
EA = 1; /* enable interrupts */
P1 = 0; //This is the port for the motors.
while (1==1)
{
int i;
int j;
for(i=0; i<xcoord;i++)
P1 = .......;
for(j=0;j<ycoord;j++)
P1 = .......;
P1 = 0;
P2 = 0;
TI = 1; //then transmit a complete signal out of serial
}
The code above shows bits of what i have so far (in C). Basically it should set up the 8051 properly.
Does anyone have any ideas how to read in 2 integers, say 0 to 350, and a end-of-transmission char?
Please post. or email me at:
godatguitar@hotmail.com
Please forgive me if this is totally wrong etc, I am new and learning....