主程序://set pll out freq 1529mhz using HMC830 hmc mode
#include "hmc830.h"
#include "pic16F688_reg.h"
//#fuses INTRC_IO,NOWDT,NOPROTECT,NOBROWNOUT,MCLR,NOCPD,NOPUT,NOIESO,NOFCMEN,BROWNOUT_NOSL
#use fast_io(C)
#BIT PLL_SEN = PORTC.2
#BIT PLL_SCK = PORTA.2
#BIT PLL_SDI = PORTC.0
#BIT LD_SDD = PORTC.3
void delay (int length)
{
while (length >0)
length--;
}
//---------------------------------
//--------------------------------------------------------------------------------
void WriteToHMC830(unsigned char count, unsigned char buf0,unsigned char buf1,unsigned char buf2,unsigned char buf3)
{
unsigned char ValueToWrite = 0;
unsigned char i = 0;
unsigned char j = 0;
delay(1);
PLL_SCK=0;
PLL_SEN=0;
delay(1);
PLL_SEN=1;
PLL_SDI=0;
delay(1);
PLL_SCK=1;
delay(1);
PLL_SCK=0;
for(i=0;i<count;i++)
{
if (i==0)
ValueToWrite = buf0;
if (i==1)
ValueToWrite = buf1;
if (i==2)
ValueToWrite = buf2;
if (i==3)
ValueToWrite = buf3;
if(i == 0)
{
ValueToWrite <<= 2;
for(j=0; j<6; j++)
{
if(0x80 == (ValueToWrite & 0x80))
{
PLL_SDI=1;
}
else
{
PLL_SDI=0;
}
delay(1);
PLL_SCK=1;
delay(1);
ValueToWrite <<= 1;
PLL_SCK=0;
}
}
else
{
for(j=0; j<8; j++)
{
if(0x80 == (ValueToWrite & 0x80))
{
PLL_SDI=1;
}
else
{
PLL_SDI=0;
}
delay(1);
PLL_SCK=1;
delay(1);
ValueToWrite <<= 1;
PLL_SCK=0;
}
}
}
delay(1);
PLL_SCK=1;
delay(1);
PLL_SCK=0;
delay(1);
PLL_SEN=0;
delay(1);
}
//#ZERO_RAM
void main()
{
OSCCON = 0x47;
OSCTUNE = 0x00;
OPTION = 0;
ANSEL = 0x00;
TRISA = 0x00;
TRISC = 0x08;
CMCON0= 0x07;
delay_ms(50);
{
//Reference frequency: 10MHz;Output frequency: 1252MHz; interger mode
do{
WriteToHMC830(4,0x00,0x00,0x00,0x20);
WriteToHMC830(4,0x00,0x00,0x00,0x00);
delay(1);
WriteToHMC830(4,0x01,0x00,0x00,0x02); //
WriteToHMC830(4,0x02,0x00,0x00,0x0A); // Reference Divider R=10=Ah ****change
WriteToHMC830(4,0x05,0x00,0xC0,0x90); // Biases -3dB,fo/1 ****change
WriteToHMC830(4,0x05,0x00,0x28,0x18); // Buffer autoRFO mode,diff out
WriteToHMC830(4,0x05,0x00,0x00,0x00); // VCO SPI
WriteToHMC830(4,0x06,0x20,0x03,0xCA); // SD CFG, set Integer mode, mode B
WriteToHMC830(4,0x07,0x00,0x0A,0xCD); // Lock Detect
WriteToHMC830(4,0x08,0xC1,0xBE,0xFF); // Analog EN
WriteToHMC830(4,0x09,0x00,0x3F,0xFF); // Charge Pump 2.54mA, offset off
WriteToHMC830(4,0x0A,0x00,0x20,0x46); // VCO AutoCal Cfg
WriteToHMC830(4,0x0B,0x07,0xC0,0x61); // PD
WriteToHMC830(4,0x0F,0x00,0x00,0xC1); // SDO as Lock Detect Output
WriteToHMC830(4,0x03,0x00,0x05,0xF9); // VCO divider Integer part 1529/1=5F9h ****change
delay_ms(100);
} while (LD_SDD==0);
}
}
求给此程序加一功能模块,,
现有一开发板,想在上面加一LED灯,使得程序烧进去单片机以后灯亮 求高手!!!
|