View Single Post
  #1   Spotlight this post!  
Unread 05-10-2008, 08:33
Leav's Avatar
Leav Leav is offline
Spud Gun Division
AKA: Leav Oz-Ari
FRC #3316 (D-Bug)
Team Role: Mentor
 
Join Date: Dec 2004
Rookie Year: 2005
Location: Technion, Haifa, Israel
Posts: 774
Leav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond reputeLeav has a reputation beyond repute
Send a message via ICQ to Leav Send a message via AIM to Leav Send a message via MSN to Leav
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

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
__________________
"We choose to build robots this season and do the other things; Not because they are easy, but because they are hard."
-Paraphrasing JFK

Participated in FIRST as a student: 2005-2006 (But still learning every season!)
Mentor: 2008 - ? (Team 2630 2008-2011, and Team 3316 since 2013)
Engineer: 2011 - ? (B.Sc. and M.Sc. in Mech. Eng. from the Technion IIT)
FIRST Volunteer - 2007 - ? (MC, FTA, FIRST Aid etc.)

Last edited by Leav : 05-10-2008 at 08:40.