Searching \ for 'rs232 + 16f84 + 4mc' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=rs232
Search entire site for: 'rs232 + 16f84 + 4mc'.

Truncated match.
PICList Thread
'rs232 + 16f84 + 4mc'
1999\10\21@211251 by Aart Arenoe

picon face
part 0 16 bytes
</x-html>

1999\10\22@013847 by Don McKenzie

flavicon
face
> Aart Arenoe wrote:
>
> Hello,
>
> i want to establesh a connection between the 16F84 and the RS232 port
> at my computer. The code i use is from the application notes from
> techtools Chapter 3, but they are talking about the 16c54 in the
> example is there a difference for this usage?

This may be what you are after:
===============================
Need RS-232 routines for PICmicros without UARTs?
Basic Stamp Compatible PIC Source Book/Disk On-Line Version Free!
Now converted to MicroChip Code, still available in Parallax Code.
Includes useful schematics.
For MicroChip code:
http://www.dontronics.com/convert.html
For Parallax code:
http://www.dontronics.com/see.html

Don McKenzie  spam_OUTdonTakeThisOuTspamdontronics.com http://www.dontronics.com

Don's Download Dungeon:   http://www.dontronics.com/download.html
Australian Electronics Ring http://www.dontronics.com/aering.html
Win $500USD Cash. Micro design contest:  http://www.simmstick.com

1999\10\22@071228 by Jose Souto

flavicon
face
part 0 14192 bytes
x-html> /*-------------------------------------------------------------------------- +
 | Asynchronous Serial communication routines for 16F848   ;             & nbsp;    |
 | Author: Jose Luiz Pinto Souto       ;             & nbsp;            &nb sp;           |
 | souto@cryogen.com         ;             & nbsp;            &nb sp;              ;        |
 | 9600 BPS, 1 start bit, 8 data bits, 1 stop bit                 &n bsp;          |
 |            ;             & nbsp;            &nb sp;              ;             & nbsp;         |
 | Compiled with CC5xFree from www.bknd.com                  &n bsp;            &nbs p;  |
 +----------------------------------------------------------------- ---------*/

/*
** 4 MHz Oscillator
*/

#include <16F84.h>
#pragma update_RP 0   /* OFF */
#define RP0          & nbsp;  STATUS.5

char rxBuf;
#pragma bit RxD_pin @ PORTA.0
#pragma bit _TxOUT  @ PORTA.1

/*----------------------------------------------------------------------- ---*/
void Delay_uSeg (char timeout)
/*---------------------------------------------------------------------- ----*/
{
    // delay = 3*timeout + 7uS (including call and return)

    while (1) {
        timeout--;
        if (timeout==0) {
            nop();
            nop();
            return;
        }
    }
}

/*----------------------------------------------------------------------- ---*/
void TxSerial (char txBuf)
/*---------------------------------------------------------------------- ----*/

/*
 ;----------------------------------------------------------------- ----------*
 ; Transmit 1 start bit Lo, 8 data bits and 1 stop bit Hi at 9600 bps
 ; No Parity
 ; Byte time = 1.040 mS
 ; Bit  time = 104 uS (0.16% erro w/4.00 Mhz Internal RC)
 ; Input : W = byte to be transmitted
 ; Output: byte transmitted by serial pin
 ;----------------------------------------------------------------- ----------*
*/

{
    char idx;

    while (1) {
        Carry = 0;   & nbsp;            &nb sp;     // start bit
        for (idx=10; idx; idx--) {      // 3us
            _TxOUT = Carry;            ;  // 4us
            Delay_uSeg(28);            ;  // 91us (28*3+7)
            Carry  = 1;          &nbs p;      // 1us
            txBuf  = rr(txBuf);         // 1us
            nop();            &n bsp;         // 1us
        }    &nbs p;                           // 3us
        return;
    }
}

/*----------------------------------------------------------------------- ---*/
void RxSerial (void)
/*---------------------------------------------------------------------- ----*/

/*
 ;----------------------------------------------------------------- ----------*
 ; Receives 1 start bit Lo, 8 data bits and 1 stop bit Hi at 9600 bps
 ; No Parity
 ; Byte time = 1.040 mS
 ; Bit  time = 104 uS (0.16% erro w/4.00 Mhz Internal RC)
 ;
 ; False start bit check
 ;
 ; Start bit hunting timeout = 4*1.283ms
 ;
 ; Input  : none
 ; Output : Carry = 1 => success
 ;          rxBuf = input byte
 ;          Carry = 0 => error (timeout or stop bit=0)
 ;----------------------------------------------------------------- ----------*
*/

{
    char idx;

    rxBuf = 4;       &n bsp;            &nbs p;     // 5.135 ms timeout
    idx   = 0;

    while (1) {
        while (RxD_pin) {                // input "high"
            if ((-- idx)==0) {
                 if ((-- rxBuf)==0) {
                     Carry = 0;
                     return;
                 }
            }
        }

        Delay_uSeg(14);  &nb sp;              ; // 1/2 bit delay (14*3+7)
        if (RxD_pin)
            continue;             ;       // false start bit detection

        rxBuf = 0x80;    ;             & nbsp;  // 8 bits counter and reception buffer
        nop();
        nop();     ;             & nbsp;        // timming adjustment

        do {
            Delay_uSeg(30);            ;  // (30*3+7)us
            Carry = RxD_pin;          &nbs p; // bit read
            rxBuf = rr(rxBuf);          // store and count
        } while (Carry==0);< /tt>

        Delay_uSeg(30);  &nb sp;              ; // 1 bit delay
        nop();     ;             & nbsp;        // timming adjustment
        Carry = RxD_pin;  & nbsp;             // stop bit read
        return;   &nbs p;                      // 100 us availiable
    }
}

/*----------------------------------------------------------------------- ---*/
void main( void)
/*---------------------------------------------------------------------- ----*/
{
        INTCON  = 0;                &n bsp;            &nbs p;       // no interrupts
        PCLATH  = 0;                &n bsp;            &nbs p;       // bank 0
        PORTA   = 0;
        PORTB   = 0;
        RP0     = 1;            &nbs p;                        // RAM bank 1
        TRISA   = 0x01;
        TRISB   = 0;
        OPTION  = 0b11000011;&nb sp;              ;             // check for your appl.
        RP0     = 0;            &nbs p;                        // RAM bank 0

    // Serial routines usage example

    char a;

    a = 0xAA;

    TxSerial(a);
    TxSerial(0x55);

    do {
        RxSerial();
    } while (Carry==0);
    a = rxBuf;

    RxSerial();
    if (Carry==1) {
        a = rxBuf;
    }
}
 

1999\10\25@060138 by Dr. Imre Bartfai

flavicon
face
Hi,

when using 16F84, the user RAM begins at 0Ch, rather than at 8. Correct
your ORG statement! And I guess, the carry must be inverted before sending
due to the MAX232.

Regards,
Imre


On Fri, 22 Oct 1999, Aart Arenoe wrote:

> Hello,
>
> i want to establesh a connection between the 16F84 and the RS232 port at my co
mputer. The code i use is from the application notes from techtools Chapter 3, b
ut they are talking about the 16c54 in the example is there a difference for thi
s usage?
> Also i'm using a the max232 as shown in the example, but all there is is rubis
h at my screen (good old term95). Is there somebody who did manage to get the pi
c talking to the RS232? I'm using the CVASM16 assambler. It's not the computer c
ause the Universal Infrared Remotecontrol works great on the same port.
{Quote hidden}

16c54
>                                                                ; into 16f84
>
> bit_K  = 24                                               ;24 for 9600-baud op
eration @ 4 MHz
> serial_out = ra.2                                        ;Output naar pin 1 va
n IC
> org     8                                                    ;Start of availab
le RAM
> delay_cntr ds 1                                         ;Counter for serial de
lay routines
> bit_cntr ds 1                                              ;Number of transmit
ted bits
> msg_cntr ds 1                                           ;Offset in string
> xmt_byte ds 1                                           ;The transmitted byte
> org     0                                                     ;Start of code s
pace (ROM)
> jmp begin                                                  ;Start Programma.
>
> begin  mov !ra, #00000000b                        ;Set port to output.
> mov msg_cntr, #0                                      ;Message string has nine
characters;
>                                                                 ;0 through 8.
> :again  mov bit_cntr,#8                               ;Eight bits in a byte.
>            mov w,msg_cntr                             ;Point to position in th
e string.
>            call string                                      ;Get the next char
acter from string.
>            mov xmt_byte,w                             ;Put character into the
transmit byte.
>
>            clrb serial_out                                 ;Change to setb ser
ial_out for direct
>                                                                 ;connection.
>
>            call bit_delay ;Start bit.
>
> :xmit    rr xmt_byte                                    ;Rotate right moves da
ta bits into
>                                                                 ;carry, starti
ng with bit 0.
>
>            movb serial_out,c                           ;Change to movb serial_
out,/c for
>                                                                ;direct connect
ion.
>
>            call bit_delay                                 ;Data bit.
>            djnz bit_cntr,:xmit                          ;Not eight bits yet? S
end next data bit
>
>            setb serial_out                               ;Change to clrb seria
l_out for direct
>                                                                ;connection
>
>           call bit_delay                                   ;Stop bit.
>           inc msg_cntr                                   ;Add one to the strin
g pointer.
>
>           cjbe msg_cntr,#8,:again
>                                                                 ;More characte
rs to send? Go to the top
>
> :endless jmp :endless                                ;Endless loop. Reset cont
roller to run
{Quote hidden}

Parallax"
>                                                                ;followed by a
linefeed.
>
>          retw 'P','a','r','a','l','l','a','x',10
>
>

1999\10\25@201245 by Aart Arenoe

picon face
----- Original Message -----
From: Dr. Imre Bartfai <.....rootKILLspamspam@spam@PROF.PMMF.HU>
To: <PICLISTspamKILLspamMITVMA.MIT.EDU>
Sent: Monday, October 25, 1999 12:01 PM
Subject: Re: rs232 + 16f84 + 4mc

Thanks!  Changing the org statement did the job! No need to invert since the
code was written for use with an max232.
To late now for trying the transmit code but i assume that will work too
(after changing the org.... )

Aart.

Aart.

{Quote hidden}

my computer. The code i use is from the application notes from techtools
Chapter 3, but they are talking about the 16c54 in the example is there a
difference for this usage?
> > Also i'm using a the max232 as shown in the example, but all there is is
rubish at my screen (good old term95). Is there somebody who did manage to
get the pic talking to the RS232? I'm using the CVASM16 assambler. It's not
the computer cause the Universal Infrared Remotecontrol works great on the
same port.
{Quote hidden}

determined
> > ; by the value of the constant bit_K and the clock speed of the PIC. See
the
> > ; table in the application note (above) for values of bit_K. For
example, with
> > ; the clock running at 4 MHz and a desired transmitting rate of 4800
baud,
> > ; make bit_K 50.
> >
> > ; >>> Remember to change device info if programming a different PIC! <<<
> > ; Do not use RC devices. Their clock speed is not sufficiently accurate
> > ; or stable enough for serial communication.
> >
> > device pic16f84,xt_osc,wdt_off,protect_off   ; changed the procesor type
from 16c54
> >                                                                ; into
16f84
> >
> > bit_K  = 24                                               ;24 for
9600-baud operation @ 4 MHz
> > serial_out = ra.2                                        ;Output naar
pin 1 van IC
> > org     8                                                    ;Start of
available RAM
> > delay_cntr ds 1                                         ;Counter for
serial delay routines
> > bit_cntr ds 1                                              ;Number of
transmitted bits
> > msg_cntr ds 1                                           ;Offset in
string
> > xmt_byte ds 1                                           ;The transmitted
byte
> > org     0                                                     ;Start of
code space (ROM)
> > jmp begin                                                  ;Start
Programma.
> >
> > begin  mov !ra, #00000000b                        ;Set port to output.
> > mov msg_cntr, #0                                      ;Message string
has nine characters;
> >                                                                 ;0
through 8.
> > :again  mov bit_cntr,#8                               ;Eight bits in a
byte.
> >            mov w,msg_cntr                             ;Point to position
in the string.
> >            call string                                      ;Get the
next character from string.
> >            mov xmt_byte,w                             ;Put character
into the transmit byte.
> >
> >            clrb serial_out                                 ;Change to
setb serial_out for direct
> >
;connection.
> >
> >            call bit_delay ;Start bit.
> >
> > :xmit    rr xmt_byte                                    ;Rotate right
moves data bits into
> >                                                                 ;carry,
starting with bit 0.
> >
> >            movb serial_out,c                           ;Change to movb
serial_out,/c for
> >                                                                ;direct
connection.
> >
> >            call bit_delay                                 ;Data bit.
> >            djnz bit_cntr,:xmit                          ;Not eight bits
yet? Send next data bit
> >
> >            setb serial_out                               ;Change to clrb
serial_out for direct
> >
;connection
> >
> >           call bit_delay                                   ;Stop bit.
> >           inc msg_cntr                                   ;Add one to the
string pointer.
> >
> >           cjbe msg_cntr,#8,:again
> >                                                                 ;More
characters to send? Go to the top
> >
> > :endless jmp :endless                                ;Endless loop.
Reset controller to run
> >
;program.
> >
> > ; To change the baud rate, substitute a new value for bit_K at the
beginning of
> > ; this program.
> >
> >          bit_delay mov delay_cntr,#bit_K
> > :loop  nop
> >          djnz delay_cntr, :loop
> >          ret
> >
> >          string  jmp pc+w                              ;String
consisting of "Parallax"
> >                                                                ;followed
by a linefeed.
> >
> >          retw 'P','a','r','a','l','l','a','x',10
> >
> >
>

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