12F675 and interrupt


Results 1 to 8 of 8

Threaded View

  1. #4
    Join Date
    Jul 2007
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Thank you all.

    I followed your directions Acetronics but and coded above. Maybe it work, maybe they need some fixes.

    Simulating (no development board in class yet) in proteus, an strange behavior occurs on GPIO.0 they always stays up, even Iīve (I think at least) disabled pullup for them. Other pins appears ok.

    What Iīve missed??

    BTW, Perides, not Pericles. But no problem, common misspelling. :-)


    Code:
    ' Pinout                                                        *
    ' 1 vdd                                             vss 8       *
    ' 2 gp5/t1cki/osc1/clkin           gp0/an0/cin+/icspdat 7       *
    ' 3 gp4/an3/t1g/osc2/clkout   gp1/an1/cin-/vref/icspclk 6       *
    ' 4 gp3/mclr/vpp                gp2/an2/tockin/int/cout 5       *
    '                                                               *
    '****************************************************************
    @ device pic12F675, WDT_OFF, PWRT_ON, MCLR_OFF, INTRC_OSC_NOCLKOUT
    define osc 4
    
    CMCON = 7 'comparator off
    ANSEL = 0 'all digital 
    'VRCON = 0 'comparator off
    
    TRISIO= %000011 '1=in 0=out 
    
    'Enable PULL-UPS
    OPTION_REG.7 = 0 'enable pullu-ps (0 enable/1 disable) 
    WPU = %000010 '1=on/0=off each pullup - enable pull-up only TK
    
    
    L15 var GPIO.0  'line 15
    TK  VAR GPIO.1  'door sensor 
    LAMP VAR GPIO.2 'bulb
    myPWM VAR word
    
    main:
       If TK = 0 Then LAMP = 1 'if TK goes down so LAMP goes UP
            
       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
    GoTo main
    
    delay:
        FOR myPWM = 1 to 500 '500 loops for 5 second of 10ms delay 
            if L15 = 1 then justfade 'if L15 goes up so end delay
            pause 10 'wait 10ms
        next myPWM
    
    justfade:
        for mypwm = 255 to 1 step -1
            PWM LAMP, myPWM, 255 'pwm bulp
            if TK = 0 then GOTO main 'if TK goes down
        NEXT myPWM
        goto main
    Last edited by perides; - 23rd September 2008 at 15:23. Reason: Added BTW line :-)

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, 14:39
  2. Interrupt usage
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th April 2008, 16:20
  3. ON INTERRUPT not working
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th April 2008, 13:41
  4. Instant Interupts with a 12f675
    By wlundonly in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th January 2008, 01: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, 19: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