Actually I was going to suggest an output of some kind, maybe an led. If MaskSwitch gets outside of your parameters in someway you could effectively end up in a main ... goto main loop.
Actually I was going to suggest an output of some kind, maybe an led. If MaskSwitch gets outside of your parameters in someway you could effectively end up in a main ... goto main loop.
OK, I've added the following
Now the LED is flashing all the time, so i presume the CASE ELSE is true, which i guess means something else is happening.Code: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 Case Else Gosub Error End Select Goto Main Error: For loop = 1 to 5 Red = 1 Pause 100 Red = 0 Pause 100 Next Loop Return
I think it may be due to the following:
What does the $07 represent. Is this saying all of the PORTS on C. If so, what will it be if i want just PORTC.0, PORTC.1 and PORTC.2.Code:MaskSwitch=PORTC & $07
Thank you, i think i'm getting there!!
I agree with IngVar,
You have no way of knowing if the case statement is something other than 1,2,4. Put a default case in there with a blinking light....If that blinking light comes on... there is your problem.
Dwayne
Ability to Fly:
Hurling yourself towards the ground, and missing.
Engineers that Contribute to flying:
Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute
Pilots that are Flying:
Those who know their limitations, and respect the green side of the grass...
Dwayne,
Is what i've done above your posting wrong then? If so, could you post the modification to the code you are suggesting.
Many thanks.
$07 = %00000111
Steve,
If you push two buttons at the same time or if you're not using pull down/up resistors you end up with MaskSwitch = %00000110 which isn't an option.
Bugger, i think it might be due to no pull-down resistors.
I've attahced my circuit, would this be the case?
What values are recommended ?
Hopefully that is the problem which is reasonably easy to fix.
Regards,
Steve
The pull-down resistors didn't make any difference, the LED keeps in the 'error' flash routine. I didn't have and 5K, so i used a 2k2, would this still perform the task? If not i have 47k?
However, i have inserted:
Adding the Goto Main routine now seems to work.Code: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 Case Else Goto Main End Select Goto Main
Although this is a work around, its still strange that some other signal is being received into the PIC which i would like to find.
Cheers.
After looking at the HiRK-433 datasheet(assuming this is the one you use http://www.okwelectronics.com/datasheets/DS.0010-2.pdf ), i say that there is no need for pulldowns(or ups). Just make sure your JP1 and 2 are not linked. This would make the outputs latching, you want them to be momentary.
/Ingvar
Yup, thats the exact one.
Ok, i'll remove the pull-down resistors.
It must be something else that is making the CASE ELSE statement true then.
Cheers,
Steve
When I am developing a project I always have a serial port available ,even if the project will not use it.Being able to check variables and ports is invaluable for debugging,versus debugging blind.
Bookmarks