Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 30th May 2008, 05:02 AM   (permalink)
Default USART interfacing with PC

Okay, here's the skinny:
I plan to use the hardware USART in the 16F876A. The software shouldn't be too hard to figure out I just need to set up the BRG and play with the registers as the datasheet dictates, I just need to get a few questions answered:

I plan to at least begin figuring out the interfacing using Hyperterminal on the PC end. The MAX232 has hookups for Tx, Rx, CTS and RTS/DTR.

I have the option to either use RTS/DTR on the RTS line, or (believe it or not) the DTR line. Which would work for Hyperterminal?

More importantly, I know to hook up Rx to Rx and Tx to Tx, but what would I hook CTS and RTS/DTR up to?
__________________
Buy it, use it, break it, fix it, trash it, change it, mail upgrade it, charge it, point it, zoom it, press it, snap it, work it, quick erase it, write it, cut it, paste it, save it, load it, check it, quick rewrite it, plug it, play it, burn it, rip it, drag and drop it, zip unzip it.
ArtemisGoldfish is offline  
Reply With Quote
Old 30th May 2008, 05:23 AM   (permalink)
Default

Quote:
Originally Posted by ArtemisGoldfish View Post
Okay, here's the skinny:
I plan to use the hardware USART in the 16F876A. The software shouldn't be too hard to figure out I just need to set up the BRG and play with the registers as the datasheet dictates, I just need to get a few questions answered:

I plan to at least begin figuring out the interfacing using Hyperterminal on the PC end. The MAX232 has hookups for Tx, Rx, CTS and RTS/DTR.

I have the option to either use RTS/DTR on the RTS line, or (believe it or not) the DTR line. Which would work for Hyperterminal?

More importantly, I know to hook up Rx to Rx and Tx to Tx, but what would I hook CTS and RTS/DTR up to?
Unless you need them for something special, don't bother connecting them. RX and TX is all you need for most things.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is online now  
Reply With Quote
Old 30th May 2008, 05:23 AM   (permalink)
Default

CTS & RTS are just flow control, they were designed to pause transmission if the receiving device wasn't ready for data (buffer full)
You may not require them.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline  
Reply With Quote
Old 30th May 2008, 06:46 AM   (permalink)
Default

Code:
 
More importantly, I know to hook up Rx to Rx and Tx to Tx
You'll probably get on better connecting Rx to Tx both ways
__________________
Pete
picprojects.org.uk
geko is offline  
Reply With Quote
Old 30th May 2008, 09:55 AM   (permalink)
Default

Quote:
Originally Posted by geko View Post
Code:
 
More importantly, I know to hook up Rx to Rx and Tx to Tx
You'll probably get on better connecting Rx to Tx both ways
But Rx and Tx (which I refer to) are printed on the prototyping board, so I suppose I hook them up Tx-Tx on the board itself.
__________________
Buy it, use it, break it, fix it, trash it, change it, mail upgrade it, charge it, point it, zoom it, press it, snap it, work it, quick erase it, write it, cut it, paste it, save it, load it, check it, quick rewrite it, plug it, play it, burn it, rip it, drag and drop it, zip unzip it.

Last edited by ArtemisGoldfish; 30th May 2008 at 09:59 AM.
ArtemisGoldfish is offline  
Reply With Quote
Old 30th May 2008, 10:39 AM   (permalink)
Default

Quote:
But Rx and Tx (which I refer to) are printed on the prototyping board, so I suppose I hook them up Tx-Tx on the board itself.
It would seem strange to label a receive input as Tx on the basis the Tx output from the remote device connects to it.

When I see Rx I expect it to be the receive input and Tx is the transmit output. Connecting Tx-Tx says to me output to output.

However, I don't know what your prototyping board is. I guess if it's indicating the connection between the PIC USART and the line driver IC maybe they have done it that way?
__________________
Pete
picprojects.org.uk
geko is offline  
Reply With Quote
Old 30th May 2008, 12:21 PM   (permalink)
Default

Olimex PIC-P28 is the board.
__________________
Buy it, use it, break it, fix it, trash it, change it, mail upgrade it, charge it, point it, zoom it, press it, snap it, work it, quick erase it, write it, cut it, paste it, save it, load it, check it, quick rewrite it, plug it, play it, burn it, rip it, drag and drop it, zip unzip it.
ArtemisGoldfish is offline  
Reply With Quote
Old 30th May 2008, 01:25 PM   (permalink)
Default

Looking at the schematic for the PIC-P28 board the labels on the PCB next to the MAX232 IC are the level converted signals from the 9-pin D connector so you would need to connect it as I originally suggested.

PIC TX pin to MAX232 RX
PIC RX pin to MAX232 TX
__________________
Pete
picprojects.org.uk
geko is offline  
Reply With Quote
Old 30th May 2008, 06:25 PM   (permalink)
Default

Okeedokee, much thanks.
__________________
Buy it, use it, break it, fix it, trash it, change it, mail upgrade it, charge it, point it, zoom it, press it, snap it, work it, quick erase it, write it, cut it, paste it, save it, load it, check it, quick rewrite it, plug it, play it, burn it, rip it, drag and drop it, zip unzip it.
ArtemisGoldfish is offline  
Reply With Quote
Old 30th May 2008, 11:37 PM   (permalink)
Default

If you are using a PICKit 2, then you don't need voltage switching devices to communicate with your PC via USART


Ok, so I hear what you are saying - the PICKit 2 will program almost every PIC known to man kind from 12Fs/16F's/18F's/dsPIC's/24F PIC's, but how do you use it for UART/USART communication with your PC? Well start off by opening the PICKit 2 programming software, and from the Tools menu, select UART Tool...


And providing you have the PIC connected to your PICKit2 correctly, then you can now send USART data directly between the two.



I did up a small tutorial explaining the process here
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline  
Reply With Quote
Old 31st May 2008, 02:35 AM   (permalink)
Default

Ah, the sweet scent of victory. Well, that's what I *think* that smell is.

One final, quick question: I know you can use the typing ex. '10011001'b for Binary, 0x99 for Hex and d'153' for decimal, but what can you use to input ASCII characters? Using lookup tables by hand is a pain.
Attached Images
File Type: jpg working.JPG (220.6 KB, 9 views)
__________________
Buy it, use it, break it, fix it, trash it, change it, mail upgrade it, charge it, point it, zoom it, press it, snap it, work it, quick erase it, write it, cut it, paste it, save it, load it, check it, quick rewrite it, plug it, play it, burn it, rip it, drag and drop it, zip unzip it.

Last edited by ArtemisGoldfish; 31st May 2008 at 02:37 AM.
ArtemisGoldfish is offline  
Reply With Quote
Old 31st May 2008, 04:02 AM   (permalink)
Default

Your examples suggest you're using assembly language. If that's the case, an ASCII literal constant operand looks like this;

Code:
        movlw   'H'             ; it can look like this
        call    Put232          ;
        movlw   a'e'            ; or it can look like these two
        call    Put232          ;
        movlw   a'l'            ;
        call    Put232          ;
You can also use lookup tables and a loop to print strings but there are a few caveats to watch out for. Plenty of good examples in Nigel's tutorials.

Other methods allow sending strings while storing them inline with your code.

Code:
;
;  examples for PIC 18F' devices
;
;
;  hyperterminal home, clear screen, print title
;
pTitle  macro   str             ; clear screen, print title
        call    PutString       ;
        db      h'1B',"[2J"     ; <esc>[2J ANSI sequence
        db      str,0           ; inline null terminated string table
        endm

PutStr  macro   str
        rcall   PutString       ;
        db      str,0           ; inline null terminated string table
        endm
;
;  example macro usage
;
        pTitle  "Hello\r\n\n"   ; clear screen + home cursor
        PutStr  "Menu\r\n"      ;
        PutStr  "<1> Config\r\n"
        PutStr  "<2> Set AOS\r\n"
        PutStr  "<X> Exit menu"
Code:
;******************************************************************
;
;  PutString - print in-line string via Stack and TBLPTR (18F)
;
;  string must be terminated with a 00 byte and does not need
;  to be word aligned
;
PutString
        movff   TOSL,TBLPTRL    ; copy return address into TBLPTR
        movff   TOSH,TBLPTRH    ;
        clrf    TBLPTRU         ; assume PIC with < 64-KB
PutNext
        tblrd   *+              ; get in-line string character
        movf    TABLAT,W        ; last character (00)?
        bz      PutExit         ; yes, exit, else
        rcall   Put232          ; print character
        bra     PutNext         ; and do another
PutExit
        btfsc   TBLPTRL,0       ; odd address?
        tblrd   *+              ; yes, make it even (fix PC)
        movf    TBLPTRH,W       ; setup new return address
        movwf   TOSH            ; 
        movf    TBLPTRL,W       ;
        movwf   TOSL            ;
        return                  ;
You can achieve the same functionality with 16F' devices but the code is quite different.

Regards, Mike

Last edited by Mike, K8LH; 31st May 2008 at 04:04 AM.
Mike, K8LH is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
usart with pic neelam29 Micro Controllers 11 9th April 2008 01:09 PM
PIC USART: Help Please mortuzahasan Micro Controllers 2 11th February 2007 06:28 PM
How or what to program into the pic to use the USART teknyc78 Micro Controllers 3 12th April 2005 07:00 AM
HELP!!! nothing going through my USART!!! Guyver Micro Controllers 8 6th May 2004 08:11 AM
Usart to Usart? Eclipsed General Electronics Chat 7 23rd October 2003 04:07 PM



All times are GMT. The time now is 06:24 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.