499549794

    1. TI 狂欢+CC2640R2通过HDC1080测量温度 11/7017 无线连接 2019-01-30
      版主,看你测得的数据挺好的,为什么我测试HDC1080温度和湿度寄存器值是一样的?主函数: void main(void) {   CLK_Config();      GPIO_Init(GPIOD, GPIO_Pin_0, GPIO_Mode_Out_PP_High_Slow);   HDC1080_Init();   enableInterrupts();   while (1)   {     Delay_ms(1000);     GPIO_ToggleBits(GPIOD,GPIO_Pin_0);     testdata[0] = HDC1080_Read_DeviceID();     testdata[1] = HDC1080_Read_ManufacturerID();        testdata[3] = HDC1080_Read_Temper();     testdata[2] = HDC1080_Read_Humidi();     //testdata[4] = HDC1080_Read_Conf();   } } 下面是我的HDC1080驱动程序: /********************************************************************************* @file       HDC1080.c @brief      Humidity and Temperature sensor 驱动模块 @details    I2C接口 @details    Copyright 2016, Testo, Ltd., Shenzhen @author     pli @date       2016.02.16 @version    00.00 编译条件: 芯片型号..-   MSP430i2041 编译器版本-   IAR for ARM - Ver6.4 优化级别..-   High balanced 修改记录: 初版00.00 *******************************************************************************/ //#include //#include "io430.h" //#include "main.h" #include "HDC1080.h" #include "I2C.h" #include "timing_delay.h" //#include /*******************************************************************************   * @brief  HDC1080_Write_Buffer   * @param  uint8_t addr is point register   * @param  uint8_t *buffer is the need to write data point   * @param  uint8_t len is the write data length   * @retval void *******************************************************************************/ void HDC1080_Write_Buffer(uint8_t addr, uint8_t *buffer, uint8_t len) {     I2C_Start();     I2C_Send_Byte(HDC1080_Device_Adderss);     I2C_Wait_Ack();     I2C_Send_Byte(addr);     I2C_Wait_Ack();     while ( len-- )     {             I2C_Send_Byte(*buffer);             I2C_Wait_Ack();             buffer++;     }     I2C_Stop(); } /*******************************************************************************   * @brief  HDC1080_Read_Buffer between triger and read there is no wait.   * @param  uint8_t addr is point register   * @param  uint8_t *buffer is the need to read data point   * @param  uint8_t len is the read data length   * @retval void *******************************************************************************/ void HDC1080_Read_Buffer(uint8_t addr, uint8_t *buffer, uint8_t len) {     uint8_t temp = 0;             I2C_Start();     I2C_Send_Byte(HDC1080_Device_Adderss);     I2C_Wait_Ack();     I2C_Send_Byte(addr);     I2C_Wait_Ack();     I2C_Stop();     while( pin_SCL_READ())     {         Delay_us(1);         temp++;         if ( temp >= 100 )         {             break;         }     }     I2C_Start();     I2C_Send_Byte(HDC1080_Device_Adderss|0x01);    //read     I2C_Wait_Ack();     while ( len-- )     {             *buffer = I2C_Recv_Byte();             buffer++;             if ( len == 0 )                 I2C_Send_NoAck();             else             I2C_Send_Ack();                           }     I2C_Stop(); } /*******************************************************************************   * @brief  HDC1080_Read_MBuffer becareful between triger and read there is a wait.   * @param  uint8_t addr is point register   * @param  uint8_t *buffer is the need to read data point   * @param  uint8_t len is the read data length   * @retval void *******************************************************************************/ void HDC1080_Read_MBuffer(uint8_t addr, uint8_t *buffer, uint8_t len) {     uint8_t temp = 0;             I2C_Start();     I2C_Send_Byte(HDC1080_Device_Adderss);     I2C_Wait_Ack();     I2C_Send_Byte(0X00);     I2C_Wait_Ack();     I2C_Stop();     while( pin_SCL_READ())     {         Delay_us(1);         temp++;         if ( temp >= 100 )         {             break;         }     }     //Delay_ms(10);      // after triger should wait at least 6.5ms     Delay_ms(10);      // after triger should wait at least 6.5ms     I2C_Start();     I2C_Send_Byte(HDC1080_Device_Adderss|0x01);    //read     I2C_Wait_Ack();     while ( len-- )     {             *buffer = I2C_Recv_Byte();             buffer++;             if ( len == 0 )                 I2C_Send_NoAck();             else             I2C_Send_Ack();                           }     I2C_Stop(); } /*******************************************************************************   * @brief  HDC1080_Soft_Reset   * @param  void   * @retval void *******************************************************************************/ void HDC1080_Soft_Reset(void) {     uint8_t temp[2];     temp[0] = 0x80;     temp[1] = 0x00;     HDC1080_Write_Buffer(HDC1080_Read_Config, temp, 2);     Delay_ms(20);//there should be waiting for more than 15 ms. } /*******************************************************************************   * @brief  HDC1080_Setting   * @param  void   * @retval void *******************************************************************************/ void HDC1080_Setting(void) {     uint16_t tempcom = 0;     uint8_t temp[2];             tempcom |= 1 8);     temp[1] = (uint8_t)tempcom;     HDC1080_Write_Buffer(0x02, temp, 2); } /*******************************************************************************   * @brief  HDC1080_Init   * @param  void   * @retval void *******************************************************************************/ void HDC1080_Init(void) {     //uint8_t temp = 0;     I2C_Init();     HDC1080_Soft_Reset();     HDC1080_Setting();     /*     while( pin_SCL_READ() )     {         Delay_us(1);;         temp++;         if ( temp >= 100 )         {             break;         }     }*/ } /*******************************************************************************   * @brief  HDC1080_Read_Temper   * @param  void   * @retval int16_t tempr value *******************************************************************************/ int16_t HDC1080_Read_Temper(void) {     uint8_t buffer[2];     HDC1080_Read_MBuffer(0x00, buffer, 2);     return ((buffer[0]

最近访客

< 1/1 >

统计信息

已有2人来访过

  • 芯积分:--
  • 好友:--
  • 主题:--
  • 回复:1

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言