Searching \ for '[PIC]: USART on 16F628' 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=usart
Search entire site for: 'USART on 16F628'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: USART on 16F628'
2001\12\24@001635 by Rudy Rudy

flavicon
face
Hi everyone,

I am working with serial communication of the 16F628, and I am getting some
strange results.  What I am trying to do is to get serial communication
through RF from my laptop to a 16F628 (for remote control application later
on).  I first set up using COM1 output of my laptop to a serial line
receiver (LM1489) that converts RS-232 voltage level to TTL level, and then
connect the TTL level output to the Serial RX line of F628.  Everything
works!  Commands are transferred through correctly (I made it to turn on and
off an LED).

So, after that I tried it through RF.  I have built my own RF "interfacer"
that will reliably transfer digital data across the Wenshing/Velleman RF
modules.  I have tested the "interfacer" many times and it works very
reliably.  The RF "interfacer" is a 12C509A.  The output of the 12C509A is
fed into the Serial RX pin of 16F628.  Now, sometimes it works (the command
is tranferred), most of the time, it doesn't.  I am very sure about the
correctness of the transmitted RF signals i.e. when I look at the signal in
a fancy digital scope, the correct serial data is received.  My intuition is
that the current output of the 12C509A (using pin 3/GP4) is not enough to
drive the Serial RX of the 16F628.  Has anyone faced this problem before?

Help please!  Thank you very much in advance.


Rudy

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\12\24@083034 by kben

picon face
Hi Rudy,
I have tried serial IR to a PIC16F628. It worked well after I slowed down
the TX/RX speed. I doubt you are having this problem with RF, but you could

try and slow down your TX/RX speed, like 2400.
The I/O pin on the PIC12C509A should have no problem driving the F628 pin.
Also, you could try outputting the TX to the RX on your PC serial port.

Good Luck,
Kevin

{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\12\24@131007 by Rudy Rudy

flavicon
face
Hi Kevin,

Yes, I have already tried it on slower speed (300 bps) and it works most of
the time (not all the time).  I am very sure that the problem is not whether
the correct data is transfered.  I look at the data inputted into the Serial
Rx of the 16F628, and the data is correct (very sure!).  It just doesn't
trigger the interrupt or something like that to let the F628 knows that
there is serial data coming.

I did try outputing TX to my PC serial port.  This works PERFECTLY!  So, I
am very sure that my RF "interfacer" chip is doing its job.  Thank you very
much.

Rudy

{Original Message removed}

2001\12\24@133037 by Rudy Rudy

flavicon
face
Hi Larry,

It's an adventure doing it without interrupt.  I totally would not recommend
this.

Yes.  That's true.  RF modules usually need sometime to "power-up" or
"lock-on" to the data first before actually receiving the data correctly.  I
think it's a pain to have to send some data (preamble or something like
that) first to activate those RF modules, and then, send the data.  Not to
mention if your data has a lot of simultaneous '1' (try sending 0xff, the RF
modules will really mess this one up).

That's why I built my own RF "interfacer" chips.  These chips take care of
that for me.  They maintain the RF transmitter and receiver active ALL the
time.  They make the RF transmission transparent, so that RF connection will
behave almost like a straight wire connection.  I can send a 0xff
continuously (I have tried it), and it gets it everytime.

Here is some code to help you with interrupt:

; Note that in the code, I also enabled serial Tx.  If you don't need this,
just get rid of it

;-- variables in memory --;
rx_byte         equ     0x20
w_temp          equ     0x70
status_temp             equ     0x71

               ORG     0x000
               goto    main

               ORG     0x004
               movwf   w_temp          ; save off current W register contents
               movf    STATUS,w        ; move status register into W register
               movwf   status_temp     ; save off contents of STATUS register

               ;-- ISR code here --;
               ; note: - I am assuming that NO OTHER interrupts are enabled but the
serial RX
               ;       - I don't try to take care of the errors, except re-enabling the
serial RX

               btfsc   RCSTA, FERR     ; does frame error occur?
               goto    Rx_error
               btfsc   RCSTA, OERR     ; any overrun error?
               goto    Rx_error

               ; everything looks good, now read data & do what you want with it
               movf    RCREG, w
               movwf   rx_byte

               ;---- do whatever you want with the data here ---;

               goto    end_of_ISR

Rx_error        movf    RCREG, w        ; read the data anyway (MUST be done)
               bcf     RCSTA, CREN     ; re-ENable RX, this clears FERR & OERR error flags as
well
               bsf     RCSTA, CREN
               ;-- end of ISR code --;
end_of_ISR
               movf    status_temp,w   ; retrieve copy of STATUS register
               movwf     STATUS                ; restore pre-isr STATUS register contents
               swapf   w_temp,f
               swapf   w_temp,w        ; restore pre-isr W register contents

               retfie                  ; return from interrupt

;------------------------;
;-- start of main code --;
;------------------------;
main            clrf    PORTB
               bsf     STATUS, RP0     ; select bank 1
               movlw   b'00000010'     ; RB1 inputs, others outputs
               movwf   TRISB

               ; setting 1200 N 8 1
               ; 1200bps, no parity, 8 data bit, 1 stop bit

               bcf     TXSTA, SYNC     ; set asynchronous
               bcf     TXSTA, BRGH     ; set low baud rate
               movlw   0x33            ; 1200bps (51 = 0x33 @ 4MHz)
               movwf   SPBRG

               bcf     STATUS, RP0     ; select bank 0
               bsf     RCSTA, SPEN     ; ENable Serial Port

               bsf     STATUS, RP0     ; select bank 1
               bsf     TXSTA, TXEN     ; ENable TX
               bsf     PIE1, RCIE      ; Enable RX interrupt

               bcf     STATUS, RP0     ; back to bank 0
               bsf     RCSTA, CREN     ; ENable RX

               ; Serial Port all set, now transmit through RB2 by loading TXREG (0x19)
               ; When data is ready to be sent again, TXIF/PIR1<4> (0x0c) is '1'

               ; receive through RB1.  RCIF will be set when reception is complete.
               ; Interrupt will be generated.  Read RCSTA (0x18) to determine any errors
               ; Read RCREG (0x1a) for the data received

               bsf     INTCON, GIE             ; Enable Global Interrupt
               bsf     INTCON, PEIE    ; Enable Peripheral Interrupt

main_loop       nop
               nop
               goto    main_loop




{Original Message removed}

2001\12\24@195824 by Jon Baker

flavicon
face
> Yes.  That's true.  RF modules usually need sometime to "power-up" or
> "lock-on" to the data first before actually receiving the data correctly.
I
> think it's a pain to have to send some data (preamble or something like
> that) first to activate those RF modules, and then, send the data.  Not to
> mention if your data has a lot of simultaneous '1' (try sending 0xff, the
RF
> modules will really mess this one up).

Hmm. I dont think FF is a good preamble obviously because it is so uniform..
better to use something like 0xE5 or 01010101 etc.. something where there is
a variance and something you can lock on to.

Jon B.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\12\24@204908 by Rudy Rudy

flavicon
face
Jon,

> Hmm. I dont think FF is a good preamble obviously because it is so
uniform..
> better to use something like 0xE5 or 01010101 etc.. something where there
is
> a variance and something you can lock on to.
>
> Jon B.

Exactly my point.  RF modules usually screw this one up.  The interfacer
chip I made is precisely designed to take care of things like that.


Rudy

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\12\24@211220 by Rudy Rudy

flavicon
face
Hi everyone,

I figured out the problem.  The serial TX/RX seem to be DTL logic, not TTL.
So, by putting a diode in serial between the 12C509 output and serial RX
input, it solves the problem.  Thanks to everyone who responded anyway.


Rudy

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


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