This is a multi-part message in MIME format.
------=_NextPart_000_0021_01C130A8.A599BEC0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0022_01C130A8.A599BEC0"
------=_NextPart_001_0022_01C130A8.A599BEC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I'm very new with pics, I have the picdem 17 protoboard, and I'm trying =
to figure out how to communicate through USART to hyperterminal on my =
computer. I can currently send data out of the pic to hyper terminal, =
but I can't seem to input any new data from the usart. any suggestions? =
Is there some hardware handshaking I need to do? I've attached the =
sample code that came with the board that I've been playing around with.
-Lori Wu
------=_NextPart_001_0022_01C130A8.A599BEC0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I'm very new with pics, I have the =
picdem 17=20
protoboard, and I'm trying to figure out how to communicate through =
USART to=20
hyperterminal on my computer. I can currently send data out of the pic =
to hyper=20
terminal, but I can't seem to input any new data from the usart. any=20
suggestions? Is there some hardware handshaking I need to do? I've =
attached the=20
sample code that came with the board that I've been playing around=20
with.
-Lori =
Wu
------=_NextPart_001_0022_01C130A8.A599BEC0--
------=_NextPart_000_0021_01C130A8.A599BEC0
Content-Type: application/octet-stream;
name="usart.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="usart.c"
//****************************************************
//* USART.C
//****************************************************
//* Rodger Richey
//* Principal Applications Engineer
//* Microchip Technology Incorporated
//****************************************************
//* 2 December 1998
//* Compiled using MPLAB-C17 V2.20
//****************************************************
//* This program prints an incrementing count from
//* 0 to 255 to the USART. The numbers are displayed
//* in the Monitor program.
//****************************************************
//* Uses an oscillator of 16MHz
//****************************************************
#include
#include
#include
#include
//#include
void PutsUSART2(char *data);
// Function to print a string to USART2 using handshaking
void PutsUSART2(char *data)
{
do
{
// Wait for USART to complete prev operation
while(BusyUSART2());
// Hardware handshaking for CTS
while(PORTBbits.RB4);
// Print a character to USART2
putcUSART2(*data);
} while(*data++); // Increment pointer and check for NULL
return;
}
=09
void main(void)
{
unsigned char i;
unsigned char j;
char temp;
char str[5];
char test[10];
char crlf[3];
// Initialize the carriage return/linefeed string
crlf[0] =3D 0x0d;
crlf[1] =3D 0x0a;
crlf[2] =3D 0;
//my testing, says "HELLO"
test[0]=3D72;
test[1]=3D 69;
test[2]=3D 76;
test[3]=3D 76;
test[4]=3D 79;
test[5]=3D0;
PutsUSART2(test);
// Initialize USART2 and the hardware handshaking lines
PORTBbits.RB5 =3D 1;
DDRBbits.RB5 =3D 0;
//PORTGbits.RX2 =3D 1;
=
OpenUSART2(USART_TX_INT_OFF&USART_RX_INT_OFF&USART_ASYNCH_MODE&USART_EIGH=
T_BIT&USART_CONT_RX,25);
// Send a carriage return and linefeed
PutsUSART2(crlf);
// Initialize the count variable
i =3D 65;
=09
while(i<255)
{
// Convert the count variable to ASCII
//ubtoa(i,str);
=09
// Print the string
//PutsUSART2(str);
WriteUSART2(i);
=09
j=3DgetcUSART2();
=09
// Wait for a while
Delay10KTCYx(250);
Delay10KTCYx(250);
=09
WriteUSART2(j);
// Print a carriage return and linefeed
PutsUSART2(crlf);
// Wait for a while
Delay10KTCYx(250);
Delay10KTCYx(250);
// Increment the count variable
i++;
=09
//getsUSART2(test, i);
/*while(temp)
{
test[i]=3D temp;
PutsUSART2(crlf);
WriteUSART2(test[i]);
i++;
temp=3DReadUSART2();
}
test[i]=3D0;*/
=09
//PutsUSART2(test);
=09
}
}
------=_NextPart_000_0021_01C130A8.A599BEC0--
--
http://www.piclist.com hint: To leave the PICList
mailto:piclist-unsubscribe-request@mitvma.mit.edu