锁相环MC145170基本控制程序

zhontan   2011-8-28 00:09 楼主
#include <REG51.h>
#define c_register 7
#define n_register 15
#define r_register 14
sbit Din = P2^1;
sbit ENB = P2^2;
sbit CLK = P2^3;

void MC145170_Reset(void)

{
unsigned char Bit_shift_counter;

Bit_shift_counter=0;
CLK=0;
ENB=1;
Din=0;

while(Bit_shift_counter<4)
{
CLK=1;
Bit_shift_counter++;
CLK=0;

}

/* ENB????,???????,Din???0? */

Bit_shift_counter=0;
ENB=0;

while(Bit_shift_counter<3)
{
CLK=1;
Bit_shift_counter++;
CLK=0;
}

/* ENB????,???????,Din?1? */
Din=1;
CLK=1;

CLK=0;

/* ENB????,???????,Din?0. */
Din=0;
CLK=1;

CLK=0;

/* ?????????,??Reset */
ENB=1;
}




void MC145170_Write_C_N_R_BitGrabber_Register(char BitGrabber_Register,unsigned int Bit_Stream)

{


CLK =0;
ENB =0;

while (BitGrabber_Register>=0)
{

Din=(Bit_Stream>>BitGrabber_Register)&0x0001; //???????????,&0x0001???

CLK=1; //???????
CLK=0;

BitGrabber_Register --;

}

ENB=1; //????

}

void main()
{
MC145170_Reset();
MC145170_Write_C_N_R_BitGrabber_Register( c_register,0x63);
MC145170_Write_C_N_R_BitGrabber_Register( r_register,5000);  
MC145170_Write_C_N_R_BitGrabber_Register( n_register,12648);
while(1);

}

回复评论

暂无评论,赶紧抢沙发吧
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复