Acidmods
AcidMods Resources ----- ( These are helpful tools for modding ) => Pic Programmers and Programs => Software => Topic started by: l0rdnic0 on March 23, 2008, 11:16:11 PM
-
Here is an Electronic switch that I have installed in a PSP Slim. This can be installed in any console and be programmed to turn on and off as many mods as you have. The nice thing about this is that it is set to any button you wish and does not interfere with that buttons original functions. To use the button all you need to do is hold it down for .5 of one second.
Keep in mind that is has been configured to turn on and off only one mod, but could be expanded to acomidate many more. Also I'm not a ASM coder so my code is not as clean as I would like but it does what its suposed to.
the modes are as follow
Mode 1:
hold button down for .5 second turns MOD one on.
Mode 2:
Hold button down for .5 second turns Mod one off .
;Software License Agreement
;
;The software supplied herewith by L0rdnic0
;Incorporated (the "Company") is intended and supplied to you, the
;Company’s customer. The software is owned by the Company and/or its supplier,
;and is protected under applicable copyright laws. All rights are
;reserved. Any use in violation of the foregoing restrictions may
;subject the user to criminal sanctions under applicable laws, as
;well as to civil liability for the breach of the terms and
;conditions of this license.
;
;THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
;WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
;TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
;PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ACIDMODS.COM SHALL NOT,
;IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
;CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
;****************************************************************************
;File Name: l0rdnic0.asm
;Author: L0rdNiC0
;Date: 24 March 2008
;Version: 1.01
;Description: Single pole, single throw switch (Can be moddified to include other functions)
;
;******************************************************************************
;Notes:
;******************************************************************************
; Each button push toggles the Switch.
; Origional code snipits taken from works by W.R.Brown Date: 2 December 2002
;
;
;******************************************************************************
list p=12F675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _CPD_OFF
; '__CONFIG' directive is used to embed configuration word within .asm file.
; The labels following the directive are located in the respective .inc file.
; See data sheet for additional information on configuration word settings.
;******************************************************************************
;Defines
;******************************************************************************
#define Bank0 0x00
#define Bank1 0x80
#define SWITCH GPIO,3
#define D0_1Tris B'11001111'
#define D0On B'00010000'
#define D0Off B'00000000'
#define D1On B'00100000'
#define D1Off B'00000000'
#define LEDOn GPIO,4
#define OneSecond D'276' ; number of Timer0 overflows in 1 sec
; when Fosc = 4MHz and prescale = 1:4
#define ChangeMode Flags,0 ; request to change the debounce mode
;******************************************************************************
;General Purpose Registers (GPR's)
;******************************************************************************
cblock 0x20
FilterCount ; debounce filter counter
OneSecH ; one second timer high byte
OneSecL ; one second timer low byte
Flags ; LED flags
CountH ; debounce counter - MS Byte
CountL ; debounce counter - LS Byte
endc
;******************************************************************************
;Reset Vector
;******************************************************************************
ORG 0x000 ; processor reset vector
nop ; required by in circuit debugger
goto Init ; go to beginning of program
;******************************************************************************
;Interrupt Vector
;******************************************************************************
ORG 0x004
return ; interrupt trap - returns without re-enabling
;******************************************************************************
;Initialization
;******************************************************************************
Init
;call 0x3FF ; retrieve factory calibration value
; comment instruction if using simulator, ICD2, or ICE2000
BANKSEL Bank1 ; BANK1
movwf OSCCAL ; update register with factory cal value
movlw D0_1Tris ; set direction so LEDs D0 & D1 are outputs
movwf TRISIO ; all others are inputs (high-z)
movlw B'11010001' ; Timer0 internal clock, 1:4 prescale
movwf OPTION_REG ; set option register for Timer0 functions
clrf ANSEL ; configure A/D I/O as digital
banksel Bank0 ; change back to PORT memory bank
movlw CM2 | CM1 | CM0 ; configure comparator inputs as digital I/O
movwf CMCON ;
clrf Flags ; set initial LED state as off
clrf FilterCount ; set initial filter count
call ToggleLED ; light initial LED
;******************************************************************************
;Main
;******************************************************************************
Main
TimerLoop
btfss INTCON,T0IF ; wait for Timer0 overflow
goto TimerLoop ;
bcf INTCON,T0IF ; clear Timer0 overflow flag
call TestSwitch ; test switch once every millisecond
btfsc ChangeMode ; request to change debounce mode? We return here
goto InitMain1 ; yes - initialize and run brute force mode
goto Main
;******************************************************************************
;Subroutines & Functions
;******************************************************************************
;******************************************************************************
;TestSwitch - Test switch state and take action when filter count saturates
;******************************************************************************
TestSwitch
btfss SWITCH ; test for switch closure
goto SwitchClosed
SwitchOpen
; When switch is open - decrement count if not already saturated
movf FilterCount,f ; move affects zero flag
btfsc STATUS,Z ; test filter count for zero
return ; count saturated - return to Main
decfsz FilterCount,f ; decrement filter count
return ; not zero - return to Main
return ; return to Main
SwitchClosed
; When switch is closed - increment count if not already saturated
btfsc FilterCount,4 ; 16 count saturation if bit 4 is high
goto TestHold ; already saturated - test button hold
incf FilterCount,f ; count up when switch is closed
btfss FilterCount,4 ; 16 count saturation when bit 4 goes high
return ; return to Main
call Reset1Second ; reload 1 second timer count
return ; return to monitor loop
ResetAndTest
bcf INTCON,T0IF ; reset Timer0 overflow flag
TestHold
; Increment negative 1 second counter and switch modes if it goes to zero
incfsz OneSecL,f ; 16 bit increment ls byte
return ; return on no overflow
incfsz OneSecH,f ; 16 bit increment ms byte
return ; return on no overflow
; one second of button holding has elapsed when both ls and ms bytes overflow
bsf ChangeMode ; button held for one second - change mode This is where the chmod happens
call ToggleLED
return
;******************************************************************************
;Reset1Second - Set 1 second counter to full count
;******************************************************************************
Reset1Second
movlw HIGH (-OneSecond & 0xFFFF) ; most significant bits of
; negative count
movwf OneSecH ; set ms register
movlw LOW -OneSecond ; least significant bits of negative count
movwf OneSecL ; set ls register
return ; return to calling routine
;******************************************************************************
;Main1 - Init Switching Debounce
;******************************************************************************
InitMain1
btfsc SWITCH ; wait in loop until SWITCH closure is sensed
goto InitMain1 ; SWITCH closure grounds input pin
call SwitchDebounce ; wait for switch to release and settle
btfss ChangeMode ; test if button held for 1 second
goto Main
InitMain0
bcf ChangeMode ; clear mode change flag
clrf FilterCount ; set initial filter count
goto Main ; change to Mode0
;******************************************************************************
;ToggleLED - Toggles D0 on and off
;******************************************************************************
ToggleLED
btfss LEDOn ; test flag of present LED condition
goto TurnLedOn ; the LED is presently off - go turn it on
TurnLedOff
bcf LEDOn ; clear flag to indicate LED is off
movlw D0Off ; data for all LED outputs low
movwf GPIO ; send data to GPIO port
return ; return to calling routine
TurnLedOn
bsf LEDOn ; set flag to indicate LED is on
movlw D0On ; data to forward bias LED0 and reverse bias LED1
movwf GPIO ; send data to GPIO port
return ; return to calling routine
;******************************************************************************
;SwitchDebounce - Waits for switch to release and settle
;******************************************************************************
SwitchDebounce
#define TenMSH D'20'
#define TenMSL D'99'
movlw TenMSH ; set outer timer loop count
movwf CountH ; outer loop overhead is 2 instructions
;========== outer loop [TenMSH * 5 instruction cycles*(Inner loop time)] ======
SD10
movlw TenMSL ; set inner timer loop
movwf CountL
;----------------- inner loop (TenMSL * 5 instruction cycles) -----------------
SD20
btfss SWITCH ; test SWITCH input
goto SwitchDebounce ; SWITCH was low - reset timer
decfsz CountL,f ; inner loop countdown
goto SD20 ; test SWITCH while counting
;-------------------------------- inner loop ----------------------------------
decfsz CountH,f ; outer loop countdown
goto SD10 ; reset inner loop after each outer loop count
;================================ outer loop ==================================
return ; full countdown and no bounces achieved - exit
END ; directive 'end of program'
-
Very nice nico! Lots of hard coding into this one, lol!
-
very nice
-
Nico what is this coded in,Basic.C# ect ect.
-
good job nico
-
ill probably have a code something like this in basic pro in a few days (if u dont care nico)
-
ware we download it?
-
thats the code in the first topic you copy and paste that into your programmer i think
-
ware do i get that?
-
if you look in the first post the quoted text is the code whick you copy and paste into your programing software (like pic basic pro) then flash it to the pic chip using a programer which can be bought from imagesco.com
-
oh i need sum chip for the program man thats money right there i guess i aint gonna be doing this mod
-
what, there like a doaller a pic
-
nice coding
-
Can you use any 8-pin PIC microcontroller, or does it have to be specific?
-
That is one cool mod sir. :clap: