Talat
I do not understand why you included the lines in red in you ISR
As I do not have a 16F1827 I can not do any testing. But after some thought I used an 18F452 to test your code and it did not work. I then compared data sheets for the 16F1827 and 18F452 and finding no reason for the lines in red I commented them out reprogramed the 18F452 and it ran. But I had to add a pause 10 in the main loop so my voltmeter could display the readings.Code:'************************************************* *************** '* Name : * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 09.08.2014 * '* Version : 1.0 * '* Notes : 16F1827 * '* : * '************************************************* *************** ' DEVİCE 16F1827 ASM __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF __config _CONFIG2, _PLLEN_ON & _LVP_OFF & _LVP_OFF & _STVREN_OFF; & _VCAPEN_OFF ENDASM CLEAR DEFINE OSC 32 OSCCON=%01110000 '32 DEFINE INTHAND PWM_INT PWM_VAL VAR WORD BANK0 SYSTEM VALUE VAR WORD INIT: APFCON0 = 0 'SET PORTB.3 TO CCP1 T1CON = %00100000 'Prescaler 1:4 PIE1.0 = 1 'TMR1IE TMR1 Interrupt Enable PIR1.0 = 0 'TMR1IF TMR1 Interrupt Flag INTCON.7 = 1 'GIE Global Interrupt Enable INTCON.6 = 1 'PEIE Peripheral Interrupt Enable CCP1CON = 9 'compare mode OUTPUT PORTB.3 'CCP PIN T1CON.0 = 1 'TMR1ON SET TMR1 PAUSE 1000 VALUE=1000 MLOOP: VALUE=VALUE+1 PWM_VAL = VALUE Goto MLOOP Asm PWM_INT movlw 9 ; compare mode clrf CCP1CON ; clear reg movwf CCP1CON ; Set reg movf PWM_VAL+1,W ; hb movwf CCPR1H ; put movf PWM_VAL,W ; lb movwf CCPR1L ; put bsf INTCON,7 ;GIE = 1 bsf INTCON,6 ;PEIE = 1 Enable peripheral interrupts bsf PIE1,0 ; TMR1IE= 1 Enable TMR1 bcf PIR1,0 ; TMR1IF = 0 Clear Timer1 Int Flag RETFIE ; Return from Interrupt EndAsm END
Here is my version
I am very interested to know if my version works on the 16F1827 that you have.Code:'************************************************* *************** '* Name : * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 09.08.2014 * '* Version : 1.0 * '* Notes : 16F1827 * '* : * '************************************************* *************** ' DEVİCE 16F1827 ASM __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF __config _CONFIG2, _PLLEN_ON & _LVP_OFF & _LVP_OFF & _STVREN_OFF; & _VCAPEN_OFF ENDASM CLEAR DEFINE OSC 32 OSCCON=%01110000 '32 DEFINE INTHAND PWM_INT PWM_VAL VAR WORD BANK0 SYSTEM INIT: APFCON0 = 0 'SET PORTB.3 TO CCP1 T1CON = %00100000 'Prescaler 1:4 PIE1.0 = 1 'TMR1IE TMR1 Interrupt Enable PIR1.0 = 0 'TMR1IF TMR1 Interrupt Flag INTCON.7 = 1 'GIE Global Interrupt Enable INTCON.6 = 1 'PEIE Peripheral Interrupt Enable CCP1CON = 9 'compare mode OUTPUT PORTB.3 'CCP PIN T1CON.0 = 1 'TMR1ON SET TMR1 PAUSE 1000 MLOOP: PWM_VAL = PWM_VAL+1 PAUSE 10 Goto MLOOP Asm PWM_INT movlw 9 ; compare mode clrf CCP1CON ; clear reg movwf CCP1CON ; Set reg movf PWM_VAL+1,W ; hb movwf CCPR1H ; put movf PWM_VAL,W ; lb movwf CCPR1L ; put bcf PIR1,0 ; TMR1IF = 0 Clear Timer1 Int Flag RETFIE ; Return from Interrupt EndAsm END




Bookmarks