Please help support the site by donating at the link below.https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8ZRU34U47BESW
WaitForTrigger BTFSS PORTC, TRIGGER, ACCESS ;wait for pulse train start BRA WaitForTrigger MOVLB 2 ;***********************R2 pulse*************************** FIRST PULSE bsf TRISC, COMMONR, ACCESS ;make digital inputs bsf TRISC, COMMONL, ACCESS movlw 0x60 ;return to comparator inputs movwf ANSEL, ACCESS bsf CM1CON0, C1ON, ACCESS bsf CM2CON0, C2ON, ACCESS BTFSC NextPressLo, C3R3, BANKED ;COM3 outputs BSF LATB, R3WRITE, ACCESS ;force press BTFSC NextPressLo, C3L3, BANKED bsf LATB, L3WRITE, ACCESS ;force press movlw 0xF6 ;setup timer movwf TMR1H, ACCESS movlw 0xAD movwf TMR1L, ACCESS bcf PIR1, 0, ACCESS bsf T1CON, 0, ACCESSTimer01 btfss PIR1, 0, ACCESS ;200usec interval goto Timer01 btfsc CM1CON0, C1OUT, ACCESS ;read button presses BSF CurPressLo, C2R2, ACCESS ;with cmparators btfsc CM2CON0, C2OUT, ACCESS BSF CurPressHi, C1DUP, ACCESS BTFSC PORTC, RCLIC, ACCESS ;read stick clicks BSF CurPressLo, C3R3, ACCESS BTFSC PORTC, LCLIC, ACCESS BSF CurPressLo, C3L3, ACCESS bcf CM1CON0, C1ON, ACCESS ;turn comparators off bcf CM2CON0, C2ON, ACCESS ;and make digital inputs clrf ANSEL, ACCESS movlw 0xF8 ;setup timer movwf TMR1H, ACCESS movlw 0x94 movwf TMR1L, ACCESS bcf PIR1, 0, ACCESS bsf T1CON, 0, ACCESSTimer21 btfss PIR1, 0, ACCESS ;160usec for 360usec total interval goto Timer21 bcf TRISC, COMMONR, ACCESS ;make commons outputs BTFSC NextPressLo, C2R2, BANKED ;force hi or lo bcf LATC, COMMONR, ACCESS BTFSS NextPressLo, C2R2, BANKED bsf LATC, COMMONR, ACCESS bcf TRISC, COMMONL, ACCESS BTFSC NextPressHi, C1DUP, BANKED ;force hi or lo bcf LATC, COMMONL, ACCESS BTFSS NextPressHi, C1DUP, BANKED bsf LATC, COMMONL, ACCESS movlw 0xF8 ;setup timer movwf TMR1H, ACCESS movlw 0x9B movwf TMR1L, ACCESS bcf PIR1, 0, ACCESS bsf T1CON, 0, ACCESSTimer11 btfss PIR1, 0, ACCESS ;160usec for 520usec total interval goto Timer11 ;***********************R1 pulse*************************** SECOND PULSE bsf TRISC, COMMONR, ACCESS ;make digital inputs bsf TRISC, COMMONL, ACCESS bcf LATB, R3WRITE, ACCESS ;force stick click release bcf LATB, L3WRITE, ACCESS movlw 0x60 ;return to comparator inputs movwf ANSEL, ACCESS bsf CM1CON0, C1ON, ACCESS bsf CM2CON0, C2ON, ACCESS movlw 0xF6 ;setup timer movwf TMR1H, ACCESS movlw 0xAD movwf TMR1L, ACCESS bcf PIR1, 0, ACCESS bsf T1CON, 0, ACCESSTimer02 btfss PIR1, 0, ACCESS ;200usec goto Timer02 btfsc CM1CON0, C1OUT, ACCESS ;read button presses BSF CurPressLo, C2R1, ACCESS btfsc CM2CON0, C2OUT, ACCESS BSF CurPressHi, C1DRIGHT, ACCESS bcf CM1CON0, C1ON, ACCESS ;turn comparators off bcf CM2CON0, C2ON, ACCESS ;and make digital clrf ANSEL, ACCESS movlw 0xF8 ;setup timer movwf TMR1H, ACCESS movlw 0x8F movwf TMR1L, ACCESS bcf PIR1, 0, ACCESS bsf T1CON, 0, ACCESSTimer22 btfss PIR1, 0, ACCESS ;160 usec goto Timer22 bcf TRISC, COMMONR, ACCESS BTFSC NextPressLo, C2R1, BANKED ;force hi or lo bcf LATC, COMMONR, ACCESS BTFSS NextPressLo, C2R1, BANKED bsf LATC, COMMONR, ACCESS bcf TRISC, COMMONL, ACCESS BTFSC NextPressHi, C1DRIGHT, BANKED ;force hi or lo bcf LATC, COMMONL, ACCESS BTFSS NextPressHi, C1DRIGHT, BANKED bsf LATC, COMMONL, ACCESS movlw 0xF8 ;setup timer movwf TMR1H, ACCESS movlw 0x98 movwf TMR1L, ACCESS bcf PIR1, 0, ACCESS bsf T1CON, 0, ACCESSTimer12 btfss PIR1, 0, ACCESS ;160 usec goto Timer12 ;***********************TRIANGLE pulse***************************
Can you do oscope screenshots while you do this testing? If not, send me the code and I will connect my Arduino up and take oscope screenshots so you can see what is going on.
Code is on Page 15.Im gonna work on the adc method when i get some time.the comparators confuse the piss out of me.
Sorry, I thought you had more and were giving us the Cliff's Notes edition. My PS3 code is just a little under 2000 lines of code.I can help you through the Comparator part if you want and if you are still interested in doing this.It'd probably be good to start a new thread though. Something like "PS3 code for the Arduino."