BasicMicro - Forums

www.basicmicro.com
It is currently Sun May 20, 2012 10:51 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: basic micro 40 and playstation 2 controller
PostPosted: Sun Mar 04, 2007 11:00 pm 
I recently posted this on the Basic Micro Atom Software Support forum but got no responses. I'm hoping maybe a post in this forum will have more luck.

I recently purchased a BasicATOM-40 Development Kit and a Sonly Playstation Controller Cable, along with an LCD 16x2 Display, from the Basic MICRO web site.

I'm having trouble reading from the controller. Basically I know I'm doing _something_ right, because I can change the controller mode and then lock it, but it seems like I'm getting nothing when trying to read from it. I know I must be really missing something.

Here's my setup: I have my PS2 controller signals (clock,att,cmd,dat) wired to P9,8,7,6. I have the +5 and GND wired to my board's VSS and VDD. I have the LCD lines DB4-7, E, RS on P0,1,2,3,4,5. LCD is powered also from the board's VSS and VDD obviously. The board is powered from the wallwart that comes with the development kit.

My code is below. I'm using Basic Micro ATOM IDE 02.2.1.1 to compile and load the chip. Like I mentioned, the controller configuration section works properly: the controller comes on, goes into analog mode, and locks there, just like I told it to, so I can't manually change it out of analog mode. If I comment out that section, the controller comes up with power and I can manually toggle in and out of analog mode with the controller mode button. So I'm pretty sure that part of things is working.

Then, my code tries to read from the controller and print the data it receives to the LCD. What's happening is everything it reads is being printed as zeroes.

Here are things I think I could be doing wrong: a) The board is not driving enough current to the controller for it to send me stuff back on the data line; b) I'm actually getting good data, but I'm printing it to the LCD panel incorrectly such that it seems like I'm getting all zeros; c) I'm doing something significantly wrong w/ SW in configuring the controller; d) I'm doing something significantly wrong w/ SW in reading from the controller; e) the atom40 SHIFTIN is clocking too fast. But I've tried a bunch of messing with things on each one of these areas and haven't had any luck. I even tried bitbanging on the controller clock and dat lines but still got zeroes, [although I have no way of being sure that my code for that was written properly, so I'm not sure if that proves anything]. Also I'm pretty sure at some point I tried with the regular LSBPOST (not the FAST version) on the SHIFTIN, but it didn't seem to make a difference.

Any illumination that can be provided would be greatly appreciated!

Thanks :)

code:

============================================

' constants for PS2 controller
px_clk CON p9
px_att CON p8
px_cmd CON p7
px_dat CON p6

psx_mode VAR byte
psx_b1 VAR byte
psx_b2 VAR byte
psx_b3 VAR byte
psx_b4 VAR byte
psx_b5 VAR byte
psx_b6 VAR byte


CLEAR

pause 20

HIGH px_clk


' configure LCD for writing

LCDWRITE 54, OUTA, [INITLCD1, INITLCD2, TWOLINE, CLEAR, HOME, SCR]



' Configure controller
LOW px_att
SHIFTOUT px_cmd, px_clk, FASTLSBPRE, [$18,$438,$08,$18,$08,$08,$08,$08,$08] ; CONFIG_MODE_ENTER
HIGH px_att
pause 100

LOW px_att
SHIFTOUT px_cmd, px_clk, FASTLSBPRE, [$018,$448,$008,$018,$038,$008,$008,$008,$008] ;SET_MODE_AND_LOCK
HIGH px_att
pause 100

LOW px_att
SHIFTOUT px_cmd, px_clk, FASTLSBPRE,[$018,$438,$008,$008,$008,$008,$008,$008,$008] ;CONFIG_MODE_EXIT
HIGH px_att
pause 100

LOW px_att
SHIFTOUT px_cmd, px_clk, FASTLSBPRE, [$018]
SHIFTIN px_dat, px_clk, FASTLSBPOST, [psx_mode8]
HIGH px_att

pause 100
LCDWRITE 54,OUTA,[$101,HOME,"mode: [",HEX psx_mode,"]"]
pause 1000



L1:
LCDWRITE 54,OUTA,[$101,HOME,"reading..."]
HIGH P27
PAUSE 100

LOW px_att
SHIFTOUT px_cmd, px_clk, FASTLSBPRE, [$18,$428]
SHIFTIN px_dat, px_clk, FASTLSBPOST, [psx_mode8,psx_b18,psx_b28,psx_b38,psx_b48,psx_b58,psx_b68]
HIGH px_att

LCDWRITE 54,OUTA,[$101, HOME, HEX psx_b1, "-", HEX psx_b2, "-", HEX psx_b3,"-", HEX psx_b4]
LCDWRITE 54,OUTA,[SCRRAM+$40, H


Top
  
 
 Post subject: Re: basic micro 40 and playstation 2 controller
PostPosted: Mon Mar 05, 2007 11:00 pm 
Offline
Citizen

Joined: Sat Mar 08, 2003 11:00 am
Posts: 40
If you put a "SEROUT S_OUT, I9600, ["Reset", 13]" at the top of your program, you'll see any resets.

I tend to use a logic analyzer in these circumstances -- the ANT-8 costs about $200, and is hugely useful. It's a USB-based logic analyzer that connects to your PC.

Another possibility is that the Data or Clock lines may need a 2.2K pullup-resistor -- on output this wouldn't be an issue, but on input the line might not go high fast enough to be read properly.


Top
 Profile  
 
 Post subject: Re: basic micro 40 and playstation 2 controller
PostPosted: Wed May 30, 2007 10:00 pm 
if you cant get the controller working i suggest just buying some switches, receiver and transmitter and making some kind of remote control


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO