赞
踩
1.STM32的3线SPI初始化:
- void spi_init()
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB ,ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_15; //SLEN
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- GPIO_ResetBits(GPIOB, GPIO_Pin_15);
- }
- void sdata_In_Init()
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB ,ENABLE);
- /*SPI SDATA PB15*/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //SDATA
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- }
-
- void sdata_Out_Init()
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB ,ENABLE);
- /*SPI SDATA PB15*/
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //SDATA
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOB, &GPIO_InitStructure);
- }
2.STM32对HMC7044的C函数:
HMC7044数据手册上的读写时序图
- void hmc7044_Write(unsigned long int addrData)
- {
- int i = 0;
-
- sdata_Out_Init();
- HMC7044_SPI_SLEN = 1;
- HMC7044_SPI_SCLK = 0;
- HMC7044_SPI_SDATA = 0;
- delay_us(5);
- HMC7044_SPI_SLEN = 0;
- //trans data
- for(i=0;i<24;i++)
- {
- HMC7044_SPI_SCLK = 0;
- data2 = ((addrData>>(23-i)) & 0x1);
- HMC7044_SPI_SDATA = data2;
- delay_us(5);
- HMC7044_SPI_SCLK = 1;
- delay_us(5);
- }
- HMC7044_SPI_SLEN = 1;
-
- }
-
- uint8_t hmc7044_Read(unsigned long int addrData)
- {
- int i = 0;
- uint8_t tempvalue = 0;
-
- sdata_Out_Init();
- HMC7044_SPI_SLEN = 1;
- HMC7044_SPI_SCLK = 0;
- HMC7044_SPI_SDATA = 0;
- delay_us(5);
- HMC7044_SPI_SLEN = 0;
- //trans data
- for(i=0;i<16;i++)
- {
- HMC7044_SPI_SCLK = 0;
- data2 = ((addrData>>(15-i)) & 0x1);
- HMC7044_SPI_SDATA = data2;
- delay_us(5);
- HMC7044_SPI_SCLK = 1;
- delay_us(5);
- }
- sdata_In_Init();
- for(i=0;i<8;i++)
- {
- HMC7044_SPI_SCLK = 0;
- delay_us(5);
- tempvalue<<=1;
- HMC7044_SPI_SCLK = 1;
- if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_15))
- {
- tempvalue++;
- }
- delay_us(5);
- }
- HMC7044_SPI_SLEN = 1;
- return tempvalue;
-
- }
3.HMC7044需要按照芯片手册的顺序进行配置:
- 1.更新配置寄存器
- 2.配置PLL2寄存器
- 3.配置PLL1寄存器
- 4.配置SYSREF寄存器
- 5.配置输出通道的分频比等
- 6.软件重启:0x01寄存器
4.HMC7044的锁定检测:
- PLL1锁定检测寄存器:
- 0x007C的bit5为1表示已锁定
- PLL2锁定检测寄存器:
- 0x007D的bit3位1表示PLL1和PLL2已锁定
5.HMC7044配置上位机,可生成配置寄存器的数据:https://download.csdn.net/download/qq_41953165/8558160466https://download.csdn.net/download/qq_41953165/85581604
6.STM32F103配置HMC的dPLL2输出2.4G程序
STM32F103配置HMC7044程序-嵌入式文档类资源-CSDN下载https://download.csdn.net/download/qq_41953165/85655161
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。