Someone helped me with this interrupt part of the code in assembly when I was creating a dimmer progam for my fan. Unfortunately I cannot get hold of that person & I don't have any knowledge of assembly, so if someone can help me correct the problem...
This is the only part of the code in assembly, rest is in PBP & I am comfortable dealing with it. Now, this following code controls the speed of a fan based on a variable DimmerVal which is a byte. In my code when I assign DimmerVal=0, fan stops & DimmerVal=255 takes it to full speed. The problem is that the fan speed sometimes variates & automatically goes back to the assigned speed after some moments, looks like some kind of synchronisation error with zero-detector input, but I am not sure because I can't understand this code. can someone help please....
Code:ISR: asm movwf wsave swapf STATUS, W clrf STATUS movwf ssave movf FSR,w movf fsave movf PCLATH, W movwf psave ; get ready to jump within the ISR page movlw ((INTHAND) >> 8) movwf PCLATH btfsc INTCON, INTF goto ZeroCrossingInt btfss INTCON, T0IF goto EndInt T0Overflow bcf INTCON, T0IF bsf _oDimmer goto EndInt ZeroCrossingInt bcf INTCON, INTF movf _DimmerVal,w movwf TMR0 bcf _oDimmer EndInt ; restore the machine state and return from interrupts movf fsave,w movwf FSR ; restore FSR movf psave,w movwf PCLATH ; restore PCH swapf ssave,w movwf STATUS ; restore Status swapf wsave,f swapf wsave,w ; restore WREG retfie endasm




Bookmarks