Hi, I am newbe to this forum and to PIC programming.
Earlier tried 2 small projects by using MPASAM, but found it bit tricky to handle. So, I am learning to use GC Basic.
I want to use 16F628 (which is available for me to play with) and screen the pulse input, and allow only certain pulses that are more than 400 mSec, as pulse output.
I wrote the following code and sucessfully compiled it. Yet to test in PIC.
*******************************
# chip 16F628, 4MHz
LET Count = 0;
LET Output = 0;
Start:
IF Input = 0 THEN
IF Count = 0 THEN
Wait 100 ms
GOTO Start
END IF
IF Count <> 0 THEN
Count = 0
Output = 0
Wait 100 ms
GOTO Start
END IF
END IF
IF Input <> 0 THEN
Count = Count + 1
IF Count = 4 THEN
Count = 0
Output = 1
Output_on:
IF Input = 0 THEN
Output = 0
Goto Start
END IF
IF Input <> 0 THEN
Wait 100 ms
Goto Output_on
END IF
END IF
IF Count <> 4 THEN
Wait 100 ms
Goto Start
END IF
END IF
**********************************
My questions are:
The 'compiled.asm' file shows that the chip is 16F819 instead of 16F628 as I wanted?.
I have not defined (not sure how to) the input and output ports in my code above, so which pins are being used?
Thanks in advance,
Ravi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I am newbe to this forum and to PIC programming.
Earlier tried 2 small projects by using MPASAM, but found it bit tricky to handle. So, I am learning to use GC Basic.
I want to use 16F628 (which is available for me to play with) and screen the pulse input, and allow only certain pulses that are more than 400 mSec, as pulse output.
I wrote the following code and sucessfully compiled it. Yet to test in PIC.
*******************************
# chip 16F628, 4MHz
LET Count = 0;
LET Output = 0;
Start:
IF Input = 0 THEN
IF Count = 0 THEN
Wait 100 ms
GOTO Start
END IF
IF Count <> 0 THEN
Count = 0
Output = 0
Wait 100 ms
GOTO Start
END IF
END IF
IF Input <> 0 THEN
Count = Count + 1
IF Count = 4 THEN
Count = 0
Output = 1
Output_on:
IF Input = 0 THEN
Output = 0
Goto Start
END IF
IF Input <> 0 THEN
Wait 100 ms
Goto Output_on
END IF
END IF
IF Count <> 4 THEN
Wait 100 ms
Goto Start
END IF
END IF
**********************************
My questions are:
The 'compiled.asm' file shows that the chip is 16F819 instead of 16F628 as I wanted?.
I have not defined (not sure how to) the input and output ports in my code above, so which pins are being used?
Thanks in advance,
Ravi
try this:
in beginning of code if potb.0 is input and porta.0 is output:
#define input portb.0
#define output porta.0
then in startup section add command to set pota.0 ar output:
dir output out
this can be ound on help section.
try to read all help for our reference an learning.
also look on example codes...
Just try :
#chip 16F628, 4MHz
instead of
# chip 16F628, 4MHz
Thanks for the suggestion. Ravi