<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-2">
<META content="MSHTML 6.00.6000.16587" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Ahoj,</FONT></DIV>
<DIV><FONT face=Arial size=2>postavil jsem si DDSku s Ad9833, bohužel se mi
nedaří měnit frekvenci. Vždy mi to po zavolání AD9833_reset() a nastavení
frekvence sice začne nějakou frekvenci generovat, ale ta se po dalším volání
SetDDSFrequency vůbec nezmění. Můžete mi poradit co s tím ? Driver jsem si psal
víceméně sám podle dokumentace a příkladů co jsem našel na internetu, takže
pravděpodobná chyba je více, než jistá.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>díky</FONT></DIV>
<DIV><FONT face=Arial size=2>Miloš</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>#define FREQ0
0x4000 </FONT></DIV>
<DIV><FONT face=Arial size=2>#define B28
(1<<13) <BR>#define HLB
(1<<12) <BR>#define FSELECT
(1<<11) <BR>#define PSELECT (1<<10)
<BR>#define ADRESET (1<<8)
<BR>#define SLEEP1 (1<<7)
<BR>#define SLEEP12 (1<<6)
<BR>#define OPBITEN (1<<5)
<BR>#define DIV2 (1<<3)
<BR>#define ADMODE (1) </FONT></DIV>
<DIV><FONT face=Arial size=2><BR>#define FSYNC PIN_B3 //select chip</FONT></DIV>
<DIV><FONT face=Arial size=2><BR>void AD9833_Write(unsigned int16 value) <BR>{
<BR>int8 clsb, cmsb; <BR><BR>clsb = (int8)value; <BR>cmsb = value >> 8;
<BR>output_low(FSYNC); <BR>delay_us(5); <BR>spi_write(cmsb);
<BR>spi_write(clsb); <BR>delay_us(5); <BR>output_high (FSYNC); <BR>}
<BR><BR>void AD9833_reset() <BR>{
<BR><BR> AD9833_Write(B28|ADRESET|OPBITEN|DIV2); //reset
<BR> AD9833_Write(B28|OPBITEN|DIV2); // square wave <BR><BR>}
<BR><BR><BR>void SetDDSFrequency(float Freq) <BR>{ <BR>unsigned long i,lsb,msb;
<BR><BR> Freq = Freq / 0.093132258; // for 25Mhz
osc <BR> i = (unsigned long)Freq; <BR> lsb = (i &
0x3fff) + FREQ0; <BR> msb = ((i>>14) & 0x3fff) + FREQ0;
<BR> AD9833_Write(lsb); <BR> AD9833_Write(msb); <BR>}
<BR>************************************Hlavni
program*****************************<BR>#include <16F819.h> <BR>#device
PASS_STRINGS = IN_RAM <BR>#fuses NOWDT, INTRC_IO,
NOPROTECT,NOBROWNOUT,NOMCLR,NODEBUG <BR>#use delay(clock=8M) <BR><BR>#use
fast_io(b) <BR></DIV></FONT>
<DIV><FONT face=Arial size=2>void main (){ <BR><BR>SET_TRIS_B(195);
<BR><BR>setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_XMIT_L_TO_H |SPI_SS_DISABLED |
SPI_CLK_DIV_4 ); <BR>AD9833_reset(); <BR>SetDDSFrequency(10000);
<BR>delay_ms(2000); <BR>SetDDSFrequency(2000); <BR>}
<BR><BR></DIV></FONT></BODY></HTML>