A little help......
Seth Wilson
Posts: 4
Long time reader, first time poster...... [noparse]:D[/noparse]
After reading Jon Williams article in NV101, I thought I could mod his code to interface an old school style NES controller to the BS2. When I hook it up and use my code, nesIn returns 255 which is all bits on from the NES controller (Even if I disconnect the latch line).
My thinking is I have a logic error in how to give the controller a kick in the pants and start reading buttons. I tried both methods detailed in the article (manual and using SHIFTIN), but still no luck.
Find below the specs for the controller and my code (heavily based on Jon's code) [noparse]:D[/noparse]
If anyone needs more info let me know.
Any help is greatly appreciated,
Thanks
Seth.
<Start of NES controller info>
········o 4
1 o o 5
2 o o 6
3 o o 7
1. +5VDC Supply
2. ?
3. ?
4. GND
5. CLK
6. Latch
7. Data out
The NES starts the show by sending a high pulse down the Latch line, which makes the 4021 (8-bit shift register) inside the controller grab and store the state of all buttons.
Then the NES sends a series of eight low pulses down the CLK line, which makes the controller shuffle bits (one for each CLK pulse) down the Data Out line according to which buttons were pressed when latched. A low bit on the Data Out line means the button is pressed.
<End NES controller Info>
After reading Jon Williams article in NV101, I thought I could mod his code to interface an old school style NES controller to the BS2. When I hook it up and use my code, nesIn returns 255 which is all bits on from the NES controller (Even if I disconnect the latch line).
My thinking is I have a logic error in how to give the controller a kick in the pants and start reading buttons. I tried both methods detailed in the article (manual and using SHIFTIN), but still no luck.
Find below the specs for the controller and my code (heavily based on Jon's code) [noparse]:D[/noparse]
If anyone needs more info let me know.
Any help is greatly appreciated,
Thanks
Seth.
<Start of NES controller info>
········o 4
1 o o 5
2 o o 6
3 o o 7
1. +5VDC Supply
2. ?
3. ?
4. GND
5. CLK
6. Latch
7. Data out
The NES starts the show by sending a high pulse down the Latch line, which makes the 4021 (8-bit shift register) inside the controller grab and store the state of all buttons.
Then the NES sends a series of eight low pulses down the CLK line, which makes the controller shuffle bits (one for each CLK pulse) down the Data Out line according to which buttons were pressed when latched. A low bit on the Data Out line means the button is pressed.
<End NES controller Info>
Comments
Based on the information presented, I would try something like this to get started.
Reset:
· LOW Latch
Main:
· GOSUB Get_NES
· DEBUG BIN8 nesData, CR
· PAUSE 100
· GOTO Main
Get_NES:
· PULSOUT Latch, 10
· SHIFTIN Dpin, Cpin, MSBPRE, [noparse][[/noparse]nesData]
· RETURN
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Thanks so much, it is working great.
Seth.