Still foundering with PIC BAsic
I made a short program to test the input switch.
It flashes a couple of LEDs and if the switch is pressed (ground pin1 GPIO1)
it by passes the later flash.
I did learn that Ihad to do the CMON callto get the 12F629 digital.
I declared no variables since the button command seems to do this.
What ever I do, it ignores my input switch.
I went to the button command, but it still ignores.
GPIO1 is 1 and then 0 when switch pressed.
I set B0 = 1 which is steady state before switch pressed. This should be unnecessary but i tried it anyway.
Everything works, it just ignores my input. Just keeps trucking on without no short loop.
Thanks
Gene
'************************************************* ***************
'* Name : Test.BAS *
'* Author : Gene Choin *
'* Notice : Copyright (c) 2009 *
'* : All Rights Reserved *
'************************************************* ***************
'* Date : 9/20/2009 2:13 *
'* Version : 1.0 *
'* Notes : TEST for 12F629 Input *
'* *
'************************************************* ***************
'TEST program for reading input on pin 1 (Physical pin 6 on 12F629 = GPIO1).
'pin1 has a 24K pull up resistor to 5V and switch to ground.
'If pin1 = 0, flash pin 4 and retest.
'If pin1 = 1. flash pin 5 also and then GOTO TEST
Symbol CMCON = $1f 'Alias $1f to CMCON
Poke CMCON, 7 'makes all digital I/O
'Variables
'Ports
Output 0 'Make GP0 the Strike output
Input 1 'Make GP1 the Run Sense in
Output 2 'Make GP2 the Filament Drive out
Input 3 'Make GP3 the MCLR in
Output 4 'Make GP4 the START LED out
Output 5 'Make GP5 the RUN LED out
'Begin Program
TEST:
pulsout 4,2000 'Marker - Pin 4 for 4 sec
High 4
Pause 4000
Low 4
Let B0 = 1 'clear B0
button 1,0,0,0,B0,0,Fil_hi
High 5 'Marker - Pin 5 for 4 sec
pause 4000
Low 5
Fil_HI:
High 2
Pause 4000 'Marker - Pin 2 for 4 sec
Low 2
GOTO TEST
end
12F629 Input read problems
Thanks for looking. I have the latest Microcode Studio and programming sw and it handles the 12F629 fine.
I've programmed it to do all kinds of functions, but it just won't read the input.
First, I do address the ports, not as TRIS0, but as each port GP1, ... directing them to be inputs or outputs.
I did add the CMCON,7 statement
And SYMBOL CMCON $1f (that was from Another advice).
The programs proceeds through the light flasing, but doesn't change when I ground GP1.
I did have one error Letting B0 = 1. It should be B0=0 to clear register.
BUTTON claims to look at pin 1, what state is is to be when pressed and when it's pressed, what to goto.
It does that but tHe BUTTON command just follows whatever I set B0 at. No update by the BUTTON command from GP1 (pin1).
I tried the "Button.BAS in the examples and it did the same. No workee! BUT, they give you only the code snippet without any setup.
' BUTTON Command
'
' Demonstrate BUTTON command. Prints working variable (in this case B0) to
' show how auto-repeat works. Prints "PRESS" when button is pressed or
' repeated.
Symbol CMCON = $1f
SYMBOL B = pin1 ' Button Input
poke CMCON,7 'all digital
'symbol GPIO=$00001000
'symbol TRISIO=$00001000
Output 0 'Make GPIO0 the Strike output
Input 1 'Make GPIO1 the Run Sense in
Output 2 'Make GPIO2 the Filament Drive out
Input 3 'Make GPIO3 the MCLR in
Output 4 'Make GPIO4 the START LED out
Output 5
Let B0 = 0 ' Zero Button Working Buffer
Loop:
Button B,0,10,5,B0,0,Skip ' Check Button (Skip if Not Pressed)
Pulsout 5, 2000
Goto Loop
Skip:
PULSOUT 4,2000 ' Indicates Button Pressed
Pause 100 ' Visual Pause
Goto Loop ' Forever