Thursday, December 22, 2011

AD9833 DDS: Update



Hello everyone,

Good news on the AD9833 DDS work from our R&D Lab.

FLASHBACK: Previously we could load the desired frequency using the PIC16F84A and display it on the Oscilloscope. (Refer to our previous post)

HOT NEWS: Now we can vary the frequency up and down. We have upgraded the Micro-controller to 16F628A as the migration is very simple. So how did we do it??? Refer to the code sample below and its very easy to figure it out. In case of any doubts, you can always leave a comment with your email or you can email us.

Also, suggestions and feedback are most welcome.

Circuit Explanation: We have used RA1 and RA2 as the up and down inputs. PORTB is used to feed the signals to the AD9833. Circuit diagram will be uploaded soon.

ASM code: Click Here

Code:

"


list      p=16F628A            
#include <P16F628a.inc>  

__CONFIG       _PWRTE_ON & _XT_OSC & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _BODEN_OFF & _CP_OFF
temp1 equ    028H
cnt equ 02AH
count1 equ 02BH
count2 equ 02CH
count3 equ 02DH
LSBreg1 equ 032H
LSBreg2 equ 033H
MSBreg1 equ 034H
MSBreg2 equ 035H
ORG     0x00 ; processor reset vector
 
movlw 07h 
movwf CMCON
  bsf STATUS,RP0
movlw b'11111111' ; RA0..RA7 inputs
movwf   TRISA

          movlw b'00000000' ; RB0..RB7 outputs
movwf   TRISB
bcf STATUS,RP0
movlw 0x7F
movwf LSBreg1

movlw 0x00
movwf LSBreg2

movlw 0x4F
movwf MSBreg1

movlw 0x0F
movwf MSBreg2

call main1
main2 call Delay
btfss PORTA,1
call inmsb
btfss PORTA,2
call demsb
goto main2

inmsb incf MSBreg2,1
call main1
return

demsb decf MSBreg2,1
call main1
return

write1
movlw 8
movwf cnt
send_loop
bcf PORTB,4 ; assume zero bit, AD9832 SDATA pin = 0
btfsc temp1,7 ; check MSBit of 8-bit word
bsf PORTB,4
nop
bcf PORTB,5
nop ; make a pulse on AD9833 SCLK pin
bsf PORTB,5
; rotate all 8 bits left (through carry)
rlf temp1,f
decfsz cnt,f
goto send_loop
return


Delay movlw 0x11
movwf count1
movlw 0x5D
movwf count2
movlw 0x05
movwf count3
Delay_0 decfsz count1,f
goto $+2
decfsz count2,f
goto $+2
decfsz count3,f
goto Delay_0
return

main1 bcf PORTB,6

movlw 0x21
movwf temp1
call write1

movlw 0x00
movwf temp1
call write1
clrf temp1
movf LSBreg1,0
movwf temp1
call write1

movf LSBreg2,0
movwf temp1
call write1

movf MSBreg1,0
movwf temp1
call write1

movf MSBreg2,0
movwf temp1
call write1

movlw 0xC0
movwf temp1
call write1

movlw 0x00
movwf temp1
call write1

movlw 0x20
movwf temp1
call write1

movlw 0x00
movwf temp1
call write1

bsf PORTB,6
return

end



"




No comments:

Post a Comment