Menu

Beginner level question

Help
2009-07-24
2013-05-30
  • - 2009-07-24

    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

     
    • Nobody/Anonymous

      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...

       
    • Nobody/Anonymous

      Just try :
      #chip 16F628, 4MHz

      instead of
      # chip 16F628, 4MHz

       
      • - 2009-07-24

        Thanks for the suggestion. Ravi

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.