#19167 - SmileyDude - Tue Apr 13, 2004 2:31 am
I just picked up a Palm m500 compatible keyboard off ebay with the hopes of connecting it to the GBA. I cracked it open, and there are only 3 wires that are connected on the dock connector for the palm: VCC, GND, and one labeled PE3 -- I'm assuming that this would be the data out.
Does anyone have any pointers on what might be needed to connect this up to the GBA? I've already checked, and the Palm uses 3.3v as well, so power shouldn't be an issue at all. I'm assuming that the PE3 connection is the data out for the keyboard -- any idea on where this should connect up on the GBA, and what I'll need to do to read the raw data?
_________________
dennis
#19177 - Lupin - Tue Apr 13, 2004 12:28 pm
Maybe you already know that site, but you can find out where to connect VCC and GND here: http://www.brolinembedded.se/projects/keyboard/
_________________
Team Pokeme
My blog and PM ASM tutorials
#19181 - SmileyDude - Tue Apr 13, 2004 2:19 pm
Hey -- thanks for that link. I had seen it a while ago, but I lost it somehow :)
But, the downside is that it looks like that board uses serial in and out, while the board I have simply uses serial out. The good thing is that I was able to figure out how to wire it up and read from it (thanks to a night of binge coca-cola drinking and chatting on #gbadev :) ).
What I did was connect the serial out of the keyboard to the SI pin on the link port (pin 3, I believe -- working off memory here). With it connected that way, you can simply (hah!) use GPIO to read that pin directly. As a bonus, you can setup the hardware to interrupt on the falling edge of the signal, so that you don't have to poll constantly.
I was able to whip up a quick test program to see if I was getting the interrupt, and after spending a few hours checking solder connections and finding out that I had a faulty cable (wiggle the connect ever so slighly, tons of interrupts :) ), I finally went to bed.
I'll post pics and code sometime in the future -- I'm still trying to work out the protocol, so it won't be for a while (hopefully a week or two, but you never know).
_________________
dennis
#20029 - SmileyDude - Fri Apr 30, 2004 6:35 am
ok, an update...
I think i've figured out the protocol... it looks like standard 9600 baud, 8-bit, no parity data. I should (in theory) be able to read this using UART mode, but instead, I can only manage to read data when the keyboard sends two bytes (on key up). And then, it's only one of the bytes. The other one gets mysteriously dropped.
I was able to determine the protocol by using the general purpose mode, and some crude timing code (but, it worked, so i can't complain :) ). On keydown, it sends a byte with the keycode. On keyup, it sends two bytes with the same data for each. There is also a funciton key that has a different keyup value.
Here is what I saw for the keydown for Q:
Code: |
---------- -------
S 0 0 0 0|1|0 0 0|S -- 0x10
--- --- |
Am I correct in thinking that that is what the GBA is expecting in 9600/8/None mode? It looks right to me, but it could be wrong I guess.
At this point, I could use general purpose I/O, and just implement the code to handle reading this data a bit at a time, but that seems kinda dumb if the hardware could possibly read it a byte at a time.
Does anyone have any suggestions?
[edit -- corrected binary values, added what I think the signal is representing]
_________________
dennis
#20031 - SmileyDude - Fri Apr 30, 2004 7:38 am
my last post tonight... i have to get some sleep sometime :)
I've also noticed that the data that I get for the keyup doesn't match what I was expecting from my measurements using the crude timing code. For keyup, I'm expecting 0x75 0x75. Instead, I get 0x3D. For the FN keyup, I'm expecting 0x9E 0x9E. Instead, I get 0x98.
Both of these values are consistent, so it's either I haven't set up UART right, I've mis-interpreted the signal, or it's just not in the format that the GBA expects it to be it.
_________________
dennis
#28165 - kill_microsoft - Wed Oct 27, 2004 4:10 pm
this stuff could be useful to me
if you succeed can you post the instructions on how to do this? would be much appreciated.
#28264 - ampz - Thu Oct 28, 2004 5:30 pm
Signal looks inverted to me... Unless you have the start bit to the right??
The GBA expects the start bit to be 0 and the stop bit to be 1.
Have you measured the signal voltages? Perhaps they are RS232 levels (positive and negative voltages). Thoose are supposed to be inverted (And could damage your GBA link port)
#28267 - SmileyDude - Thu Oct 28, 2004 5:38 pm
ampz wrote: |
Signal looks inverted to me... Unless you have the start bit to the right??
The GBA expects the start bit to be 0 and the stop bit to be 1.
Have you measured the signal voltages? Perhaps they are RS232 levels (positive and negative voltages). Thoose are supposed to be inverted (And could damage your GBA link port) |
So, if they are inverted, is there a quick and easy way to invert them quickly? As far as voltage goes, the GBA and the Palm use the same voltage levels -- but, as you pointed out, possibly inverted :)
BTW -- if the levels are just inverted, I don't understand how it could damage the link port? Or were you referring to RS232 levels as damaging?
_________________
dennis
#28295 - ampz - Fri Oct 29, 2004 6:33 am
I was reffering to the RS232 levels as damaging.
Which bit is your start bit, the bit to the left or the bit to the right?
#28312 - SmileyDude - Fri Oct 29, 2004 1:53 pm
ampz wrote: |
Which bit is your start bit, the bit to the left or the bit to the right? |
The left bit.
_________________
dennis
#28321 - ampz - Fri Oct 29, 2004 5:12 pm
You sure? Then how do you get 0x10??
Code: |
---------- -------
S 0 0 0 0|1|0 0 0|S -- 0x10
--- --- |
UARTs transmit MSB first IIRC.
#28324 - SmileyDude - Fri Oct 29, 2004 5:29 pm
ampz wrote: |
You sure? Then how do you get 0x10??
Code: | ---------- -------
S 0 0 0 0|1|0 0 0|S -- 0x10
--- --- |
UARTs transmit MSB first IIRC. |
oops -- that would be due to a misunderstanding on my part -- so, that should be a 0x07, right?
i'm taking a look at my original notes -- there are 10 bits transmitted per keypress -- start, 8 bits of data, stop bit. The start I have down as a 1/on, stop as a 0/off.
here is the patten i have down for Q -- I've replaced the S's with their actual bit -- it reads from left to right, with the start bit being that first one, and the stop bit being the 0 on the end.
Code: |
---------- -------
1 1 1 1 1|0|1 1 1|0
--- --- |
I can't recall why I had inverted the bits earlier -- maybe that's been part of my problem. if the GBA expects starts to be 0 and ends to be 1, maybe I just need to invert the data before it connects into the GBA to get it to read properly.
So, the question becomes where can i get an inverter cheaply that will work fine with the GBA's link port? :)
_________________
dennis
#28325 - tepples - Fri Oct 29, 2004 6:00 pm
ampz wrote: |
UARTs transmit MSB first IIRC. |
That's not my understanding. At least this page claims that RS-232 sends LSB first.
Yes, you may need to run the data through an inverter, part 74HC04 (EDIT: corrected; thanks to those who pointed this out, as I had my head full of NES mapper hardware at the time). This part gives you six independent inverters, so that you can use one on the output line as well if you must.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
Last edited by tepples on Sun Oct 31, 2004 7:19 pm; edited 1 time in total
#28429 - gb_feedback - Sun Oct 31, 2004 9:14 am
Quote: |
... you may need to run the data through an inverter, part 74HCT04... |
If he needs an inverter, it should probably be a 74HC04 as he's using 3.3V.
http://www.semiconductors.philips.com/acrobat_download/datasheets/74HC_HCT04_3.pdf
_________________
http://www.bookreader.co.uk/
#28440 - ampz - Sun Oct 31, 2004 10:54 am
tepples wrote: |
ampz wrote: | UARTs transmit MSB first IIRC. |
That's not my understanding. At least this page claims that RS-232 sends LSB first. |
Sorry. You are right.
tepples wrote: |
Yes, you may need to run the data through an inverter, part 74HCT04. This part gives you six independent inverters, so that you can use one on the output line as well if you must. |
HCT is for 5V logic, he need a HC, LV or LVC (3.3V logic).
It can also be done with a NPN transistor and two resistors:
Code: |
o---\/\/\--- +3.3V
|
|
o----------- GBA serial in
|
b |/ c
Keyboard -----\/\/\---|
|\ e
|
|
GND
|
The resistor values are not very critical, anything in the 1k-47k area should work.
#28539 - SmileyDude - Tue Nov 02, 2004 4:06 pm
I am happy to report that I was able to read from the keyboard using UART mode -- it did end up being an invert problem, but the solution was actually pretty easy. It turns out that this board has 4 connections -- VC, GND, DATA and -DATA (not actually labeled that way, but they should be :). I was connecting to the same data pin that was used by the palm connection. When I moved the connection to the other one, I was able to use UART mode on the GBA.
The really nice thing was that my values that I had painstakingly extracted from my earlier timings were correct. I only had one mistake which was painfully obvious when I went back and look at the original notes :)
So, now onto my next question -- I'm currently not using FIFO mode but I'm using interrupt mode. All of the key downs are sent as 1 byte, but the key ups are sent as 2 bytes (9E 9E for FN up, 85 85 for all other key ups). I only see these as 1 byte -- I suspect that I am losing them in the interrupt, but I'm not sure. If I turn on FIFO mode, I still get the same results. Key ups only have a single interrupt, and as far as I can tell, only one byte of data.
If I use FIFO mode, is there any way of telling how many bytes are available? Should I be getting a single interrupt per byte, or should I be emptying the FIFO every interrupt? I would prefer to empty the FIFO, but again, how do I tell how full it is? :)
_________________
dennis