I have a small developmement which uses a PIC18F2550 (for later USB integration). At the moment, it takes 3 inputs from an RF module and depending on what button is pushed on the fob, jumps to a certain routine.
The only problem is that it works for about a minute, then doesn't.
If there is no activity, does the PIC goto sleep as such. I haven't come across this before if it does !!
Here is my code:
If you disconnect the power and then straight away reconnect, its still in a locked state. You have to remove power, wait about 8 seconds and then reconnect and all is fine, for a little while anyway! Most strange.Code:Clear Define OSC 20 'Define LOADER_USED 1 CMCON = 7 'disable comparators ' -----[ I/O Definition ]----------------------------------------- TRISA = %11111111 ' Set PORTA to all input TRISB = %10000001 ' Set PORTB (0)INPUT (1-5)OUTPUTS TRISC = %11111111 ' Set PORTC to all input PORTB = 0 ' ----- System Outputs ----- Red VAR PORTB.1 ' All LEDs connected ' between RC pins and ' ground via resistor ' ----- System Inputs ----- SW1 Var PORTC.0 SW2 Var PORTC.1 SW3 Var PORTC.2 ' -----[ Variable Definitions ]----------------------------------- Loop Var Byte MaskSwitch Var Byte Gosub Ready ' ************************************************************ ' * Main Program Section * ' ************************************************************ Main: MaskSwitch=PORTC & $07 Select Case MaskSwitch Case 1 '%00000001 or SW1 Gosub Procedure_SW1 Case 2 '%00000010 or SW2 Gosub Procedure_SW2 Case 4 '%00000100 or SW3 Gosub Procedure_SW3 End Select Goto Main Ready: For Loop = 1 to 5 Red = 1 Pause 50 Red = 0 Pause 50 Next Loop Return Procedure_SW1: Pause 10000 ' 20 second delay For Loop = 1 to 5 Red = 1 Pause 100 Red = 0 Pause 100 Next Loop Return Procedure_SW2: red = 1 pause 5000 red = 0 Return Procedure_SW3: for loop = 1 to 5 red = 1 pause 125 red = 0 pause 250 red = 1 pause 125 red = 0 pause 250 next loop Return
Thank you


... and me), however i've never used this particular one. My guess is that your RF module gives out combinations that won't get caught by your SELECT CASE statement(0,3,5,6,7). Easily checked by adding CASE ELSE


Bookmarks