In SX Microcontrollers, SX/B Compiler and SX-Key Tool, yllawwally wrote: Here is the code, I stripped out everything but the code to test for buttons x,y, and z. Attached is a description of the interface for 6 button sega controllers, in text format. [code] ;-------------------------- DEVICE DIRECTIVES -------------------------- DEVICE SX28,OSC4MHZ,TURBO IFDEF __SASM ;SASM Directives DEVICE STACKX,OPTIONX IRC_CAL IRC_SLOW ELSE ;Parallax Assember Directives DEVICE STACKX_OPTIONX ENDIF RESET Initialize ;---------------------------- DEBUG SETTINGS --------------------------- FREQ 4_000_000 ;------------------------ INITIALIZATION ROUTINE ----------------------- Initialize ;Port Direction Configuration at 4mhz each clock is 4.25u sec Timer = $10 GenXYZ EQU 24 Joystick_Mid equ $0E ;XXX,XXX,XXX,XXX,XXX,X,Y,Z Joystick_Low equ $0D ;XXX,C Button,XXX,B Button,Right,Left,Down,Up Joystick_High equ $0F ;XXX,XXX,XXX,A Button,B Button, X Button, Y Button, Z Button Joystick_M_wip equ $1E Joystick_L_wip equ $1D Joystick_H_wip equ $1F mov W,#$1F ;Allow Direction configuration mov M,W mov !rb,#%11111111 ;Set port B bits 0-7 to input mov !ra,#%00000000 ;Set port A bits 0-7 output bit 0 is select mov !rc,#%00000000 ;Set port C bits 0-7 output clrb ra.0 ;turn select off ;------------------------ Pause MACRO mov Timer, #18 ;1 cycle :Loop decsz Timer ;2 cycles or 4 cycles jmp :Loop ;3 cycles ENDM ;------------------------ bp0 pause setb ra.0 ;turn select off, setting voltage to 5 pause clrb ra.0 ;turn select on, setting voltage to 0 nop setb ra.0 ;turn select off, setting voltage to 5 nop clrb ra.0 ;turn select on, setting voltage to 0 nop setb ra.0 ;turn select off, setting voltage to 5 nop clrb ra.0 ;turn select on, setting voltage to 0 nop ;------------------- should be select on data now mov w, rb mov Joystick_Mid, w jnb rb.0, light ;check first bit, which should be button z jmp nolight light: clrb rc.6 ;turn off led jmp bp0 nolight: setb rc.6 ;turn on led setb ra.0 ;turn select off, setting voltage to 5 nop clrb ra.0 ;turn select on, setting voltage to 0 nop jmp bp0 ;----------------------------- ;---------------------------- MAIN PROGRAM ----------------------------- Main jmp bp0 [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=406732#m407058 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)