beginer help needed


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Mar 2014
    Location
    Pakistan
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: beginer help needed

    thankyou sir ur reply was helpful, i have another question to ask, my device is pic 16f72 and port b is digital
    when a programm run in a loop how can i intrrupt it for example
    main:
    high portb.7
    pause 100
    low portb.7
    pause 100
    goto main
    ------
    now this loop keep repeating how can i intrrupt this loop ? if i write like this
    main:
    high portb.7
    pause 100
    low portb.7
    pause 100
    goto main
    if portb.2=0 then
    portb.7 = 0
    endif
    ------------
    intrrupt here doesnt work what is the way out to get out of the loop now

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: beginer help needed

    main:
    high portb.7
    pause 100
    low portb.7
    pause 100
    if portb.2=0 then goto EXIT 'test for exit 1 time for each loop
    goto main
    EXIT:
    portb.7 = 0
    remaining code goes here...........


    OR
    main:
    high portb.7
    if portb.2=0 then goto EXIT 'test for exit after setting port pin high
    pause 100
    low portb.7
    if portb.2=0 then goto EXIT 'test for exit after setting port pin low
    pause 100
    goto main
    EXIT:
    portb.7 = 0
    remaining code goes here...........
    Last edited by Dave; - 20th March 2014 at 12:02.
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,627


    Did you find this post helpful? Yes | No

    Default Re: beginer help needed

    Hi,
    There are several ways of doing it.
    One way is to actually use a hardware interrupt, another way is to simply poll the input periodically as you go thru the loop. Yet another way is to move away from the loop structure and use a state machine aproach instead. Instead of using PAUSE, which "blocks" the processor, you can use hardware timers, either with interrupts or by simply polling the interrupt flag. It really depends on what you want to do and how fast you need to do it.

    If all you want to do is blink the LED untill an input goes high (or low) then you basically had it in the first example you posted. The drawback there is that the input is only checked once per iteration thru the loop so if the PAUSE is long there will be a long "reaction time".

    As you see there's not a single answer to your question, it all depends....

Similar Threads

  1. PBP 3.0 really needed?
    By Mugelpower in forum FAQ - Frequently Asked Questions
    Replies: 30
    Last Post: - 17th December 2017, 20:19
  2. Beginer problems
    By luxornet in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th February 2010, 05:55
  3. Beginer Help!
    By MINHLE in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 5th July 2008, 04:57
  4. Help Needed
    By Bizhub in forum General
    Replies: 1
    Last Post: - 30th June 2007, 21:18
  5. Help needed to troubleshoot
    By ssocs45 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th February 2004, 19:00

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts