PDA

View Full Version : PIC to PC



mike20200
- 15th August 2007, 17:06
Im using PIC16F877A with 20Mhz. I want connect my PIC via a MAX232 and using Hyperterminal to check the echo whatever i type in.... Can anyone pls give me some example...Im a newbie on PIC

Darrel Taylor
- 15th August 2007, 19:16
From your other thread...

i was using Hyperterminal and wanted to obtain echo from the PIC16F877A. The crystal im using is 20Mhz. BUt there was no echo at all can anyone pls help me

DEFINE OSC 20
DEFINE Ser2_BBITS 8
TRISC = %10111111

PinIn VAR PORTC.7
PinOut VAR PORTC.6
B1 VAR Byte
SerIn2 PinIn, T2400,
SerOut2 PinOut, T2400, [B1]

END.

can anyone pls help me. Im a beginner...


If you are using SERIN[b]2, then you need to use mode numbers as specified in the manual, or this webpage http://www.melabs.com/resources/ser2modes.htm.

Constants like T2400 can only be used with SERIN (without the 2).

mike20200
- 16th August 2007, 11:06
Thx alot taylor
can anyone tell me what the different between SERIN n SERIN2.... I stil cant get the echo feedback by my PIC to the hyperterminal even i try many many times with different code Can anyone pls give me some example n some advice n some idea

Bruce
- 16th August 2007, 15:03
SERIN\SEROUT were originally made to be compatible with the older BASIC Stamp 1 syntax.

The BASIC Stamp 1 was very limited in what it could do, and these commands are also very
limited. I.E. they do not support the list of modifiers shown in the PBP manual for SERIN2 or
SEROUT2, DEBUG, HSERIN, HSEROUT, etc,,.

To use T2400 you would need to insert include "MODEDEFS.BAS" in the beginning
section of your code to use the serial MODE names.

Or create a CONstant like T2400 CON 0, or SYMBOL T2400 = 0.

SERIN2\SEROUT2 were made to be compatible with the higher-end BASIC Stamp2. How they
work & the difference between these commands is shown in the PBP manual.

The back section of the manual shows SERIN2\SEROUT2 MODE examples.

This should work with SERIN2\SEROUT2;


DEFINE OSC 20

Char VAR BYTE[20] ' 20 byte array for serial data
CR CON 13 ' constant value of a carriage return

Main:
' receive up to 20 characters, optionally terminated by CR
SERIN2 PORTC.7,396,[STR Char\20\CR]

' echo back the received string of characters
SEROUT2 PORTC.6,396,[STR Char,13,10]

' clear the string
CLEAR

GOTO Main

END
Since you're already using the hardware USART pins, you might want to consider using
HSERIN & HSEROUT.

This should work with HSERIN\HSEROUT;


DEFINE OSC 20
DEFINE HSER_CLROERR 1

Char VAR BYTE[20] ' 20 byte array for serial data
CR CON 13 ' constant value of a carriage return

Main:
' receive up to 20 characters, optionally terminated by CR
HSERIN [STR Char\20\CR]

' echo back the received string of characters
HSEROUT [STR Char,13,10]

' clear the string
CLEAR

GOTO Main

END
DEBUG and DEBUGIN are also options.