![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
========================= Futz's Microcontrollers & Robotics ========================= |
||
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
Code:
More importantly, I know to hook up Rx to Rx and Tx to Tx |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
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? |
||
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
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.
__________________
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. |
|
|
|
|
|
|
(permalink) |
|
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 ;
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 ;
Regards, Mike Last edited by Mike, K8LH; 31st May 2008 at 04:04 AM. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| 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 |