1 Hz to 170 Hz is the range I mentioned, But This DDS is seems to have much costlier system design I feel Mr. Mike, But We have more better options rite ? Cost effective etc.....
As per the Above Blocks , Adjust the resistance and do better system....
Very Cost Effective one Rite ? Accurate , Simple....!
Why That Much Complications, use even 1.1 Hz Incriment ........
;******************************************************************
; 100 to 10000 pulse-per-minute DDS square wave ISR engine *
;******************************************************************
org 0x004
;
; setup PWM for a 920-usec (1086.96-Hz) period using the 8-MHz
; internal oscillator, timer 2 prescaler = 16, and PR2 = 114.
;
; [COLOR=Magenta]void interrupt() // 920-usec/1086.96-Hz interrupts[/COLOR]
; [COLOR=Magenta]{ pir1.TMR2IF = 0; // clear timer 2 interrupt flag[/COLOR]
; [COLOR=Magenta]accu += FlashPerMinute; // bump phase accumulator[/COLOR]
; [COLOR=Magenta]ccpr1l = 0; // duty cycle 0%, output 'lo'[/COLOR]
; [COLOR=Magenta]if(accu.15) // if hi portion of square wave[/COLOR]
; [COLOR=Magenta]ccpr1l = 115; // duty cycle 100%, output 'hi'[/COLOR]
; [COLOR=Magenta]} //[/COLOR]
;
radix dec
v_interrupt
movwf w_isr ; save WREG |B?
swapf STATUS,W ; doesn't change STATUS bits |B?
movwf s_isr ; save STATUS reg |B?
clrf STATUS ; bank 0 |B0
bcf PIR1,TMR2IF ; clear TMR2 interrupt flag |B0
;
; add phase offset (100..10000) to phase accumulator
;
movf fpm_l,W ; phase offset lo |B0
addwf accu_l,F ; add to phase accumulator lo |B0
skpnc ; carry? no, skip, else |B0
incf accu_h,F ; add in carry |B0
movf fpm_h,W ; phase offset hi |B0
addwf accu_h,F ; add to phase accumulator hi |B0
;
; set duty cycle to 0% (lo) or 100% (hi) for next PWM period
;
movlw 0 ; duty cycle 0%, output 'lo' |B0
btfsc accu_h,7 ; if hi portion of square wave |B0
movlw 115 ; duty cycle 100%, output 'hi' |B0
movwf CCPR1L ; set PWM duty cycle |B0
;
; restore context
;
swapf s_isr,W ; |B0
movwf STATUS ; restore STATUS |B?
swapf w_isr,f ; don't change STATUS |B?
swapf w_isr,W ; restore WREG |B?
retfie ; return from interrupt |B?
;******************************************************************
Hi sandeepa,
You're very welcome Sir.
I realize the DDS theory and math may be daunting but you have to admit it reduces down to relatively simple and elegant code.
May I ask what you're doing with this 100-10000 pulse-per-minute application?
Good luck on your project.
Kind regards, Mike
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?