Fan regulator - Any advise


Results 1 to 11 of 11

Threaded View

  1. #11
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    Hi Alain - I really needed coffee. Too much stress I guess. I mistook it for a 16F device!!! haha

    OTOH 64 bytes RAM should be good enough to do asm interrupts no?

    This is what I did with the 16F628 interrupts.
    Code:
    ' define the interrupt handler
    define      INTHAND       _IntHandler
    ' These variables are used to save the machine state on interrupt
    wsave       var byte    $20     SYSTEM          ' location for W if in bank0
    wsave1      var byte    $A0     SYSTEM          ' location for W if in bank1
    wsave2      var byte    $120    SYSTEM          ' location for W if in bank2
    ssave       var byte    BANK0   SYSTEM          ' location for STATUS register
    psave       var byte    BANK0   SYSTEM          ' location for PCLATH register
    fsave       var byte    BANK0   SYSTEM          ' location for FSR register
    
    IntHandler:
    asm
          movwf   wsave           ; Save the W register
          swapf   STATUS, W
          clrf    STATUS          ; Point to bank 0
          movwf   ssave           ; Save the STATUS register
          movf    PCLATH, W       ; Save PCLATH
          movwf   psave
          movlw   ((INTHAND) >> 8)        ; Set PCLATH for jump
          movwf   PCLATH
    
          btfss INTCON, INTF    ; branch if PULSEIN arrived
          goto  EndInt
    
    ; your code goes here
    
          ; restore the machine context
    EndInt
          movf  fsave,w         ;restore the FSR
          movwf FSR
          movf  psave,w         ;restore PCH
          movwf PCLATH
          swapf ssave, W        ;restore STATUS
          movwf STATUS
          swapf wsave, F
          swapf wsave, W        ;restore W
          retfie
    endasm
    I have not checked the datasheet for the banks used in the 12F629, but the wsave registers may need to change accordingly. Otherwise, the context save and restore takes just 4 bytes of RAM !!!!

    That also answers Damien as to the code needed for the CONTEXT RESTORE of proton

    Last edited by Jerson; - 28th August 2009 at 13:12. Reason: added code

Similar Threads

  1. Proportional fan control. I suck at math!
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 3rd January 2010, 23:10
  2. 12f635 & fan regulator
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th August 2009, 22:10
  3. Transistor selection, PWM fan control
    By 124C41 in forum Schematics
    Replies: 5
    Last Post: - 22nd December 2008, 15:33
  4. help with fan controller X10
    By iova in forum General
    Replies: 2
    Last Post: - 11th August 2006, 00:37
  5. Replies: 9
    Last Post: - 30th August 2005, 06:33

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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