GP2X Using The Serial Port


Dimacus

Member
Joined
Jan 25, 2006
Messages
349
Age
37
Location
Land of the 'åäö'
Website
luminare.no-ip.org
Hello everyone.
The other day I was tinkering with a toy RC car and a parallel port on an old computer,
and after a little soldering I made a simple interface between them, so, using the two channels
on the remote control for the car, I could send data to the computer.
now after a little more work, I acually got two computers to send data too eatchother.
And then it accured to me, "I wonder if i can do the same thing with the GP2X?"

Now from what I have heard, it's somewhat more difficult to use a serial port rather than a parallel port.
(since you have to send the data and control bits using only one signal line)
but I was thinking something like using shiftregisters to convert the serial data to parallel data, and then
send data on one line and a enable on another.

now my question is, how do I write and poll(or modify the interrupt table) the serial RX and TX lines?
do the function _outp(adr,data) work?
and if so, at what adress does the serial lines lie?


Thanks!
/Dimacus
 
I don't udnerstand what you are trying to accomplish.

Are you trying to get a gp2x to talk a pc, or to a toy RC car?

The 2X runs linux, and the serial is default output device, so writing something simple like printf("o"); will actually send the character "o" down the serial port at 115200 baud, 8, n, 1. To connect this to a PC, you'll need a MAX232 or similar as the serial ports work at different voltages (roughly 12V on PC, and 3.3V on the GP2X).

To control a toy RC car, I'd say the easiest way is to connect the 2X to a PIC or similar microcontroller - it can then receive the serial data from the 2X, and give you output pins to drive your RC car. Try to get a PIC with hardware UART, then you can just receive a character from the 2x and convert it to switch on certain things rather than having to implement a uart in software, which can be quite tricky at 115200 baud.

Don't forget though that since the serial is the default output device, you could get unsolicited messages from the Linux kernel, so you'll need to ignore these (eg. look into ways of packetising your data, or perhaps only use characters 127 - 255).
 
Im sorry I wasn't very clear.
No, im not trying to controll an RC car, or talk to a computer.

What i want to do, is to create a kind of wireless gp2x network, which could transfer X & Y position in a game of pong for example.
Also, since i want it to be cheap im thinking of going with optocouplers instead of a MAX232.

also, since I want to learn how all this works, I want to write my own communication protocol, and that would require direct access to puting binary data on the port.
 
A wireless gp2x network? Well, if your not connecting the 2x to a pc, then you don't need the max232, as the likelyhood is that whatever your talking to is going to be roughly the same voltage anyway.

You can reconfigure the speed, parity, data bits, stop bits quite easily if you still want to go with a rs-232 like communications protocol.

Or, you can disable the UART completely, and bit bang GPIOD (after setting up the DDR of course), which will give you direct access to the uart pins, so you'll be able to set the TX and possibly RX (depending on how GPH wired it up) independantly. My guess is that you'd still want a receive line anyway though. You'll then be able to do your own protocol instead of rs232'ish.

I'd put some buffering onto your circuit though - processor pins don't normally like a big load like 5mA, so drive it through a tranny.
 
Hmm, I have to admitt that i didn't quiet understand the GPIOD and setting up the DDR part.


But if my guess is right, this basicly means that i disable UART, adressing the TX and RX signal lines directly (D0 & D1 in the GPIO wikipage, altough i don't really see how to use it.)
and then writing my own program to code,write,read and decode the serial data.
 
I placed an example of using the GPIO to control the backlight on the Wiki, so that should give you enough information on how to actually control the GPIO pins.

For the DDR, look at GPIODALTFNHI and GPIODALTFNLO in the MMSP2 datasheet (section 11-4, addresses 0xC0001046 and 0xC0001026). They are most likely allocated as an alternate(ALT) function, you'll be needing them as standard input/output. Note that you may need to disable the UART itself before you can change these values - look at somewhere around section 10-13 for that.
 
Back
Top