|
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
|