Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   EduFRC Serial Port Help (http://www.chiefdelphi.com/forums/showthread.php?t=69469)

Leav 05-10-2008 08:33

EduFRC Serial Port Help
 
Hi!

(this is a followup to this thread.)

I am trying to communicate between the old EduRC controller and my nokia phone using the TTL port.

according to this page most nokia phones use the F-BUS protocol:
Quote:

F-Bus is the later high-speed full-duplex bus. It uses one pin for transmitting data and one pin for receiving data plus the ground pin. Very much like a standard serial port. It is fast 115,200bps, 8 data bits, no parity, one stop bit. For F-Bus the data terminal ready (DTR) pin must be set and the request to send (RTS) pin cleared.
My question is:

How do I set the parameters on Kevin's code to match the ones specified above?

Here is the code segment which I think sets all the parameters for serial port 2 (TTL, right?):
Code:

void Init_Serial_Port_Two(void)
{
        // Start by initializing the serial port with code
        // common to receive and transmit functions
        SPBRG2 = BAUD_9600;        // baud rate generator register [200]
                                //
        TXSTA2bits.BRGH = 0;        // high baud rate select bit (asynchronous mode only) [198]
                                //  0: low speed
                                //  1: high speed
                                //
        PIE3bits.RC2IE = 0;        // receive interrupt enable bit [95]
                                //  0: disables received data interrupt
                                //  1: enables received data interrupt
                                //
        PIE3bits.TX2IE = 0;        // transmit interrupt enable bit [95]
                                //  0: disables transmit register empty interrupt
                                //  1: enables transmit register empty interrupt
                                //
        TXSTA2bits.SYNC = 0;        // USART mode select bit [198]
                                //  0: asynchronous mode
                                //  1: synchronous mode
                                //
        TXSTA2bits.CSRC = 0;        // clock source select bit (synchronous mode only) [198]
                                //  0: Slave mode (clock generated by external source)
                                //  1: Master mode (clock generated internally from BRG)

        // if receive functionality is to be included in the
        // software build, include code that is specific to
        // initializing the receiver
        #ifdef ENABLE_SERIAL_PORT_TWO_RX
                                //
        TRISGbits.TRISG2 = 1;        // make sure the RG2/RX2/DT2 pin is configured as an input [120]
                                //
        RCSTA2bits.RX9 = 0;        // 9-bit receive enable bit [199]
                                //  0: 8-bit reception mode
                                //  1: 9-bit reception mode
                                //
        RCSTA2bits.ADEN = 0;        // address detect enable bit (9-bit asynchronous mode only) [199]
                                //  0: disables address detection
                                //  1: enables address detection
                                //
        RCSTA2bits.SREN = 1;        // single receive enable bit (master synchronous mode only) [199]
                                //  0: disables single receive mode
                                //  1: enables single receive mode
                                //
        RCSTA2bits.CREN = 1;        // continuous receive mode enable bit [199]
                                // asynchronous mode:
                                //  0: disables receiver
                                //  1: enable receiver
                                // synchronous mode:
                                //  0: disables continuous receive
                                //  1: enables continuous receive until CREN is cleared [199]
                                //
        IPR3bits.RC2IP = 0;        // receive interrupt priority bit (must be 0 for IFI controllers) [98]
                                //  0: low-priority
                                //  1: high-priority
                                //
        PIE3bits.RC2IE = 1;        // receive interrupt enable bit [95]
                                //  0: disables received data interrupt
                                //  1: enables received data interrupt
        #endif                        //

        // if transmit functionality is to be included in the
        // software build, include code that is specific to
        // initializing the serial port transmitter
        #ifdef ENABLE_SERIAL_PORT_TWO_TX
                                //
        stdout = _H_USER;        // use this driver for output stream functions
                                //
                                //
        TRISGbits.TRISG1 = 0;        // make sure the RG1/TX2/CK2 pin is configured as an output [120]
                                //
        TXSTA2bits.TX9 = 0;        // 9-bit transmit enable bit [198]
                                //  0: 8-bit transmission mode
                                //  1: 9-bit transmission mode
                                //
        IPR3bits.TX2IP = 0;        // transmit interrupt priority bit (must be 0 for IFI controllers) [98]
                                //  0: low-priority
                                //  1: high-priority
                                //
        PIE3bits.TX2IE = 1;        // transmit interrupt enable bit [95]
                                //  0: disables transmit register empty interrupt
                                //  1: enables transmit register empty interrupt
                                //
        TXSTA2bits.TXEN = 1;          // Enable transmitter [198]
                                //  0: serial transmitter is disabled
                                //  1: serial transmitter
        #endif                        //

        // finally, turn on the serial port
        RCSTA2bits.SPEN = 1;          // Serial Port Enable [199]
                                //  0: serial port is disabled
                                //  1: serial port is enabled
}

can you help me understand how to set these parameters? I can guess some like baud rate but not sure about others like whether I am using synchronous or asynchronous mode and there are just too many combinations to test them all :ahh:

Also:
Quote:

The next step is to synchronize the UART in the phone with your PC or microcontroller. This is done by sending a string of 0x55 or 'U' 128 times. Simple! The bus is now ready to be used for sending frames.
1)does this mean I'm using synchronous communications?
2)how do I send, manipulate and receive HEX data in C? in this instance I can just send 'U' (I guess), but what if I need to send 0x01 or 0xFF? do I just send the char equivalent? (FF is 255 so I can cover 0x00 to 0xFF in a char variable so that does make sense...)



Thanks alot!
-Leav

bear24rw 05-10-2008 13:27

Re: EduFRC Serial Port Help
 
As for this part..

For F-Bus the data terminal ready (DTR) pin must be set and the request to send (RTS) pin cleared.

Since the eduRC's ttl port only has +5 Rx Tx Gnd you will need to tie those two lines to a digital input/output port +5 and ground...

Leav 07-10-2008 16:40

Re: EduFRC Serial Port Help
 
Thanks!

I think though that since I am using a direct TTL connection this part is not applicable for me.

any idea regarding the parameters?

-Leav


All times are GMT -5. The time now is 00:13.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi