Hello you guys,
I know how to connect the computer to the PIC via USB (PIC18F4550), and also I can connect both PIC and GPS (Parallax GPS - Serial). Both of them I connect to PIN 26(Rx),25(Tx). My question now, how can I connect both of them, meaning to connect the GPS to the Controller, and from the controller to the controller USB???
Any ideas?
How to connect 2 usart (USB,GPS) on the same pic?
-
- Posts: 9
- Joined: 01 Nov 2009 23:41
Normally you would use a "soft" usart to generate the slower serial data in software.
So you would use the hardware usart for the USB, and make a soft usart for the GPS.
Your MikroC compiler should have soft usart library functions.
So you would use the hardware usart for the USB, and make a soft usart for the GPS.
Your MikroC compiler should have soft usart library functions.
Using; EasyPic4, EasyPIC6, BigPic4, MikroC. MPLab, MPASM.
C since 1991, PIC asm since 1998. Author of many freeware and open-source goodies; www.RomanBlack.com Designer of the www.TalkBotBrain.com talking PIC project.
C since 1991, PIC asm since 1998. Author of many freeware and open-source goodies; www.RomanBlack.com Designer of the www.TalkBotBrain.com talking PIC project.
-
- Posts: 9
- Joined: 01 Nov 2009 23:41
Thanks "The_RB" for your reply,
When I opened the example pages, to see the soft ware UART, it gave me the following:
Which pin in port C is TX and which is Rx???
Thanks!
When I opened the example pages, to see the soft ware UART, it gave me the following:
Code: Select all
unsigned short data = 0;
unsigned short recOK;
void main() {
Soft_Uart_Init(PORTC, 7, 6, 19200, 0); // initialize Soft UART
while (1) {
do {
data = Soft_Uart_Read(&recOK); // receive data
} while (recOK);
Soft_UART_Write(data); // send data via UART
}
}//~!
Thanks!
-
- Posts: 619
- Joined: 05 Jul 2008 06:05
- Location: Thailand
That's going to be very difficult with GPS data, Soft_Uart functions have no flow control or buffer so there's no way to know when new data has arrived and if you don't read the byte before the next one arrives you will lose it. As GPS data is a constant stream it will be very easy to run into problems.Normally you would use a "soft" usart to generate the slower serial data in software.
So you would use the hardware usart for the USB, and make a soft usart for the GPS.
In the Soft_Uart example, Rx is on pin 7 and Tx is on pin 6, it's in the help files.
Forgive me for asking but on the 4550 the USB lines are on RC4 & 5 and the Uart is on RC6 & 7. Why the conflict?