hi friends I use stm32f4 and I try this code with ad9850 module.
but there is a problem I think.Because when I debug data_to_load and frequency_to_load parameters never take a value.
can you check this and if you have a sample code can you share with me
#include "stm32f4_discovery.h"
//d8 w_clk
//d9 frequency update
//d10 data
//d11 reset
GPIO_InitTypeDef GPIO_InitStructure;
int i,b;
void delay(uint32_t count);
void Load_Frequency(long long frequency_to_load);
void load_bytes(uint16_t data_to_load);
void PIN_Initing(void)
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE);
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_15;
GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_100MHz;
GPIO_Init(GPIOD,&GPIO_InitStructure);
}
void load_bytes(uint16_t data_to_load)
{
for(i=0;i<8;i++,data_to_load>>=1)
{
GPIO_WriteBit(GPIOD,GPIO_Pin_10,(data_to_load & 0x01));
GPIO_SetBits(GPIOD,GPIO_Pin_8);
delay(0x00000010);
GPIO_ResetBits(GPIOD,GPIO_Pin_8);
}
}
void Load_Frequency(long long frequency_to_load)
{
long long freq=frequency_to_load*4294967295/125000000;
for(b=0;b<4;b++,freq>>=8)
{
load_bytes(freq & 0xFF);
}
delay(0x0000050);
load_bytes(0x0000);
GPIO_SetBits(GPIOD,GPIO_Pin_9);
}
void delay(uint32_t count)
{
while(count--)
{
}
}
int main(void)
{
PIN_Initing();
GPIO_SetBits(GPIOD,GPIO_Pin_15);
GPIO_SetBits(GPIOD,GPIO_Pin_11);
GPIO_SetBits(GPIOD,GPIO_Pin_8);
GPIO_SetBits(GPIOD,GPIO_Pin_9);
delay(0x0000F00);
Load_Frequency(10.e6);
while(1)
{}
}