Searching \ for '[PIC]: Serial to a terminal screen' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=serial
Search entire site for: 'Serial to a terminal screen'.

Exact match. Not showing close matches.
PICList Thread
'[pic]: Serial to a terminal screen'
2000\12\15@151149 by Peter May

flavicon
face
Is it possible to kook up a one pin out of a 16F84 as a serial out, to a
serial port on my computer and run a plain old terminal screen so I can send
some values to watch? I gather I would have to hook the pin to the data in
on the serial and gnd to gnd? It is just for test purposes.

Any ideas?

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\15@154123 by Drew Vassallo

picon face
>Is it possible to kook up a one pin out of a 16F84 as a serial out, to a
>serial port on my computer and run a plain old terminal screen so I can
>send
>some values to watch? I gather I would have to hook the pin to the data in
>on the serial and gnd to gnd? It is just for test purposes.
>

Sure, it's possible, but not trivial.  While I haven't actually done any
serial port control via PIC, I've seen it mentioned on several websites in
my travels.  The quick answer is "NO", it is NOT possible just to hook up
the PIC pin to the SDA line.  The serial port uses different voltage levels
for communication (both + and - bias), which requires a serial chip to
convert the TTL levels from the PIC to meaningful levels for the serial
port.  Most people apparently use a Maxim MAX232 chip for this.

Try this link for information:
http://www.piclist.com/techref/microchip/rs232.htm

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\15@185423 by Bob Blick

face
flavicon
face
On Sat, 16 Dec 2000, Peter May wrote:

> Is it possible to kook up a one pin out of a 16F84 as a serial out, to a
> serial port on my computer and run a plain old terminal screen so I can send
> some values to watch? I gather I would have to hook the pin to the data in
> on the serial and gnd to gnd? It is just for test purposes.

Yes, just hook it up to pin 2 of a regular DB9 connector. The PC wants
to know something is there hardware-wise, so usually I tie pins 7 and 8
together, and also pins 4 and 6 together.

Ground on the DB9 connector is pin 5.

As far as software on the pic, you need to generate time delays equal to
one baud of time, after first sending a start bit(make the pin high) and
shove out the byte one bit at a time by shifting(rotating) right(send the
least significant bits first).

Make sure you send a stop bit(low) after your byte, actually it's good to
delay two stop bits of time.

OK, that sends serial out, but if you use a terminal, it expects ascii, so
you should also create another routine that makes two ascii hex characters
out of a byte so you can send that. A 16 element lookup table works well,
called twice(once for each nibble).

If you want this all in Hi-Tech C I can send.

Also if you are using a timer-based interrupt you can do it transparently
and not hold up your program execution for each byte, but I have no idea
what your program looks like

Cheerful regards,

Bob

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\15@215421 by JB

flavicon
face
This works too, use it all the time for direct PIC>PC diagnostics (no MAX232). Probably better ways, but if it's not broke..

Call SendHexByte with your value in W, with a 4MHz clock and the PC set for 9600,N,8,1.

JB

#define serout  PORTB,1

;don't forget to define your variables: MYBYTE, BITCNT, DD

Sendbyte:
       movwf   MYBYTE
       call    Delay100uS      ;2x stop bit
       call    Delay100uS      ;a little over kill here
       call    Delay100uS      ;2x stop bit
       call    Delay100uS
       call    Delay100uS      ;2x stop bit
       call    Delay100uS
       call    Delay100uS      ;2x stop bit
       call    Delay100uS
       bsf     serout          ;startbit 1t logic low
       call    Delay100uS
       movlw   D'8'
       movwf   BITCNT
bitlp:
       rrf     MYBYTE,f        ;lsb first
       btfss   STATUS,C
       goto    sendlow
sendhigh:
       bcf     serout          ;direct-connect so invert
       goto    bitset
sendlow:
       bsf     serout
       goto    bitset          ;this would fall through, but
                               ;keeps bit timing symmetrical
bitset:
       call    Delay100uS      ;1t each bit
       decfsz  BITCNT,f
       goto    bitlp
       bcf     serout  ;stop bit 1t logic high
       return

SendHexByte:
       movwf   DD
       swapf   DD,W
       call    hextab
       call    Sendbyte
       movf    DD,W
       call    hextab
       call    Sendbyte
       return

hextab:
       andlw   H'0F'   ;be sure
       addwf   PCL,f   ;
       retlw   '0'
       retlw   '1'
       retlw   '2'
       retlw   '3'
       retlw   '4'
       retlw   '5'
       retlw   '6'
       retlw   '7'
       retlw   '8'
       retlw   '9'
       retlw   'a'
       retlw   'b'
       retlw   'c'
       retlw   'd'
       retlw   'e'
       retlw   'f'

Delay100uS:
       movlw   D'31'
       movwf   AA
lpA:    decfsz  AA,f
       goto    lpA
       nop
       nop
       return

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\15@231748 by Roman Black

flavicon
face
Drew Vassallo wrote:
>
> >Is it possible to kook up a one pin out of a 16F84 as a serial out, to a
> >serial port on my computer and run a plain old terminal screen so I can
> >send
> >some values to watch? I gather I would have to hook the pin to the data in
> >on the serial and gnd to gnd? It is just for test purposes.
> >
>
> Sure, it's possible, but not trivial.  While I haven't actually done any
> serial port control via PIC, I've seen it mentioned on several websites in
> my travels.  The quick answer is "NO", it is NOT possible just to hook up
> the PIC pin to the SDA line.  The serial port uses different voltage levels
> for communication (both + and - bias), which requires a serial chip to
> convert the TTL levels from the PIC to meaningful levels for the serial
> port.  Most people apparently use a Maxim MAX232 chip for this.
>
> Try this link for information:
> http://www.piclist.com/techref/microchip/rs232.htm


It is possible however to hook any PIC pin up to the
parallel port, through a 390 ohm resistor. I have done
this with a number of circuits, and being a quick PC
programmer I often build a PIC circuit, hook a couple
of its pins to my PC via parallel port, and write a
quick PC program to check the PIC pins and tell me
if everything is working.

So you can connect one PIC pin to the PC, just
need to hook your serial program to a different port
pin. :o)
-Roman

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2000\12\16@012505 by Bob Blick

face
flavicon
face
/*

I tested this at 2400 and 9600 baud with a 4 MHz xtal. Have fun.

Cheers,

Bob Blick
*/

/*
*      bit-banged serial out for pic16x84 uses time-wasting delays
*      based on "serial.c" sample by Hi-Tech software
*      no inverter needed, just hook to PC serial port (don't forget ground too)
*/

#include        <pic.h>
__CONFIG(FOSC0 | CP);   //this is for XT (4 megahertz or less) oscillator

const char hex_tbl[] = {48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70
};//hex lookup

//      Transmit port bit
static bit      TxData @ (unsigned)&PORTB*8+1;  // pin RB1, change to suit

//      Xtal frequency
#define XTAL    4000000

//      Baud rate
#define BRATE   9600

//      Don't change anything in these next 3 items
#define DLY             3               /* cycles per null loop */
#define TX_OHEAD        13              /* overhead cycles per loop */
#define DELAY   (((XTAL/4/BRATE)-(TX_OHEAD))/DLY)
#if (DELAY > 255)
#error choose higher baud rate or use lower frequency crystal
#endif

// output a raw byte or character
void putch(char c) {
       unsigned char   dly, bitno;

       TxData = 1;                     // start bit
       bitno = 12;
       do {
               dly = DELAY;    // wait one bit time
               do
                       ;       // nothing loop
               while(--dly);
               if(c & 1)
                       TxData = 0;
               if(!(c & 1))
                       TxData = 1;
               c = (c >> 1) | 0x80;    // setting the top bit as it shifts
       } while(--bitno);               // form stop bit and guard time
}

//outputs a byte as two hex characters
void puthex(unsigned char hexnum) {
       unsigned char nib;
       nib = hex_tbl[(hexnum >> 4)];
       putch(nib);
       nib = hex_tbl[(hexnum & 0x0F)];
       putch(nib);
}

//write a string of characters out the serial port
void puts(const unsigned char * s) {
       while(*s)
               putch(*s++);
}

//you can guess what this does
void main() {
       unsigned char i = 0;
       TRISB = 0;
       puts("Hello World");
       putch(0x0D);    //carriage return
       putch(0x0A);    //line feed
       while(++i < 25) //fill up a line with numbers
       {
               puthex(i);
               putch(0x20);    //space
       }
       while(1);       //endless loop
}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2000\12\16@144717 by Olin Lathrop

face picon face
> The PC wants
> to know something is there hardware-wise, so usually I tie pins 7 and 8
> together, and also pins 4 and 6 together.

You can skip this.  If you only want to send data from the PIC to the PC,
then you only need to connect the data line to pin 2 and ground to pin 5.
You can leave all the others open.

Pins 7 and 8 are used for hardware flow control.  Make sure you select flow
control NONE in Hyperterm.  Pins 4 and 6 are used for modem handshaking,
which you can ignore for this purpose.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, .....olinKILLspamspam@spam@embedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...