interrupt the 240ac power line by using the pin rb0/int(zero crossing detector) of pi


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by texas5 View Post
    "PortA = PortA -1, although I don't think I'd use this method. I'd use another variable to do the counting and then copy that variable into portA"

    what method do you prefer to use???what is the meaning of PortA = PortA -1 in this case???sory to ask,i'm a newbie in this thing.thanx once again for your reply...
    If you use PortA = PortA - 1, you may run into issues with the PIC.
    PortA=PortA - 1 will read the actual values on the pins, subtract one, and write it back.
    Sounds good in theory, doesn't always work that way in practice. Might work well, might not.
    I think a better way would be to read that PortA value into a temporary variable, subtract 1, then write that value back. At least then you have a copy of that value in that temporary variable to mess with, and without messing with the actual Port itself.

  2. #2
    Join Date
    Aug 2008
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    thanx.actually,u has help me a lot.one more thing...can i compile the coding using microcode studio basic pro???
    Last edited by texas5; - 10th September 2008 at 03:49.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by texas5 View Post
    thanx.actually,u has help me a lot.one more thing...can i compile the coding using microcode studio basic pro???
    What 'coding'?

  4. #4
    Join Date
    Aug 2008
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    nothing.sory.hehe.i've tested my hardware today.it's work man.thanx to you.i modify the above code into:

    DEFINE OSC 8
    TRISA.1=0
    TRISA.2=0

    MAIN:

    INTCON.4 = 1 ;enable RB0/INT interrupts
    INTCON.7 = 1 ;enable all un-masked interrupts

    if INTCON.1 = 1 Then ;RB0/INT interrupts occured
    goto EDGE
    ENDIF

    EDGE:

    IF OPTION_REG.6=1 then ;interrupt on rising edge
    LOW PORTA.1
    else
    OPTION_REG.6=0 ;interrupt on falling edge
    LOW PORTA.2
    endif

    GOTO MAIN

    thanx once again...

Similar Threads

  1. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  4. having problems with Hantronix 20x4 lcd
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 22nd December 2005, 12:22
  5. error on compiling
    By parker in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th June 2005, 14:31

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