12F675 and interrupt


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Sorry, but simulator behaviour is something making me laugh too much ...

    my last program didn't want to run on MPSIM ... but has been working more than fine for two weeks now ... ( Was a periodic signal generator, interrupt driven ...)

    sooo, I can't help you further in the virtual world ...

    Alain

    BTW ... Periclès was for joke ...
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Jul 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Hi Alain

    I agree with you about sims.
    The code appears to be in the right way at least?

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    I never use pullups ...

    you should try to add external resistors ... even on the sim' ...

    you also should avoid PWM command for such uses ... this outputs an awful garbage ( just usable with a RC filter to make a basic D/A converter. )

    as you have written the program ...

    it is easy to do it like that :

    Code:
     for mypwm = 1000 to 0 step -1
            High LAMP
            PAUSEUS myPWM,
            LOW Lamp
            PAUSEUS (1000 -myPWM)
    Next myPWM
    note PAUSEUS has a minimum duration ... but it is not a problem here !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    The code seems to be ok;
    To make it even easier to see, drop the red part.

    Code:
       IF TK = 1 and LAMP = 1 then 'if TK goes down and LAMP is yet on
          IF L15 = 1 THEN 'and we have canceled delay
             goto justfade 'so go to fade lamp
           else
             GOTO delay 'and if delay was not canceled go to delay+fade
           endif
       ENDIF
    
    and, just use this:
    
       IF TK = 1 and LAMP = 1 then delay


    Also, your PWM routine happens so fast that your eyes will not catch the fade effect.
    Have a timer loop, say 5ms, in your pwm loop, like "while : wend" and put your pwm pulse inside this "while : wend". Thus, you have a smooth fade effect.

    None of these modifications will make your GPIO pin work though.
    Just some ideas to make your code better.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. 12F675 A/D and GPIO sleep interrupt
    By macinug in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th September 2008, 15:39
  2. Interrupt usage
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th April 2008, 17:20
  3. ON INTERRUPT not working
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th April 2008, 14:41
  4. Instant Interupts with a 12f675
    By wlundonly in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th January 2008, 02:52
  5. inputs on 12F675 (or for that matter any PIC)
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th April 2007, 20:43

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