This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TLA2528:TLA2528

Guru**** 2382480 points
Other Parts Discussed in Thread: TLA2528
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/1028872/tla2528-tla2528

器件型号:TLA2528

您好!

请在下面找到代码和原理图。 对于通道0、我能够读取数字数据。 但是、当我将模拟通道更改为通道1时、我无法读取通道1数据。 即使对通道1进行了通道配置、我也会获得相同的通道0数据。

连接了 Sch

通道0配置代码:

a)头文件

   /* system_status 寄存器*/
   #define system_status_address                                  0x00
   #define SYSTEM_STATUS_DEFAULT                                  0x80

   /* SEQ_STATUS 字段*/
   #define SEQ_STATUS_MASK                                        0x40
   #define SEQ_STATUS_STOPPED                                     默认为0x00   //
   #define SEQ_STATUS_Running                                     0x40

   /* I2C_SPEED 字段*/
   #define I2C_SPEED_MASK                                        0x20
   #define I2C_SPEED_NORMAL                                     默认为0x00   //
   #define I2C_SPEED_HIGH                                        0x20

   /* OSR_DONE 字段*/
   #define OSR_DONE_MASK                                        0x08
   #define OSR_DONE 等待                                     默认为0x00  //
   #define OSR_DONE_COMPLETE                                     0x08

   /* CRC_ERR_FUSE 字段*/
   #define CRC_ERR_FUSE_MASK                                     0x04
   #define CRC_ERR_FUSE_OK                                     默认为0x00  //
   #define CRC_ERR_FUSE_ERROR                                     0x04

   /* CRC_ERR_IN 字段*/
   #define CRC_ERR_IN_MASK                                        0x02
   #define CRC_ERR_IN_OK                                        默认为0x00 //
   #define CRC_ERR_IN_ERROR                                     0x02

   /* BOR 字段*/
   #define BOR_MASK                                           0x01
   #define BOR_OK                                           0x00
   #define BOR_ERROR                                           0x01 //默认值



/*寄存器0x01 (General_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                      RESERV[3:0]                      |    CNVST   |   CH_RST   |     CAL    |     RST    |
 *|---------------------------------------------------------------- |
 *

   /* General_CFG 寄存器*/
   #define General_CFG_ADDRESS                                     0x01
   #define General_CFG_DEFAULT                                     0x00

   /* CNVST 字段*/
   #define CNVST_MASK                                           0x08
   #define CNVST_NORMAL SCL_LEADDETLED_                               默认为0x00 //
   #define CNVST_START_NO_LEVN                                  0x08

   /* CH_RST 字段*/
   #define CH_RST_MASK                                           0x04
   #define CH_RST_NORMAL                                        默认为0x00 //
   #define CH_RST_FORCE_AIN                                     0x04

   /* CAL (校准)字段*/
   #define CAL_MASK                                           0x02
   #define CAL_COMPLETE                                        默认为0x00 //
   #define CAL_START                                           0x02

   /* RST 字段*/
   #define RST_MASK                                           0x01
   #define RST_COMPLETE                                        默认为0x00  //
   #define RST_START                                           0x01



/*寄存器0x02 (DATA_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|   fix_PAT  |  保留  |     append_status[1:0]    |                      保留[3:0]                      |
 *|---------------------------------------------------------------- |
 *

   /* DATA_CFG 寄存器*/
   #define DATA_CFG_ADDRESS                                     0x02
   #define DATA_CFG_DEFAULT                                     0x00

   /* FIX_PAT 字段*/
   #define FIX_PAT_MASK                                        0x80
   #define FIX_PAT_NORMAL                                        默认为0x00 //
   #define FIX_PAT_ENABLE                                        0x80

   /* append_status 字段*/
   #define append_status_mask                                     0x30
   #define append_status_disable                                  默认为0x00  //
   #define append_status_ID                                     0x10
   #define append_status_only                                     0x20



/*寄存器0x03 (OSR_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                              RESERV[4:0]                             |                 OSR[2:0]                 |
 *|---------------------------------------------------------------- |
 *

   /* OSR_CFG 寄存器*/
   #define OSR_CFG_ADDRESS                                        0x03
   #define OSR_CFG_DEFAULT                                        0x00

   /* OSR 字段*/
   #define OSR_MASK                                           0x07
   #define OSR_1                                              默认为0x00   //
   #define OSR_2                                              0x01
   #define OSR_4                                              0x02
   #define OSR_8                                              0x03
   #define OSR_16                                              0x04
   #define OSR_32                                              0x05
   #define OSR_64                                              0x06
   #define OSR_128                                              0x07



/*寄存器0x04 (OPMODE_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|               保留[2:0]              |   OSC_SEL  |                       CLK_DIV[3:0]                      |
 *|---------------------------------------------------------------- |
 *

   /* OPMODE_CFG 寄存器*/
   #define OPMODE_CFG_ADDRESS                                     0x04
   #define OPMODE_CFG_DEFAULT                                     0x00

   /* OSC_SEL 字段*/
   #define OSC_SEL_MASK                                        0x10
   #define OSC_SEL_HIGH_SPEED                                     默认为0x00  //
   #define OSC_SEL_LOW_POWER                                     0x10



/*寄存器0x05 (PIN_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                     PIN_CFG[7:0]                                                    |
 *|---------------------------------------------------------------- |
 *

   /* PIN_CFG 寄存器*/
   #define PIN_CFG_ADDRESS                                        0x05
   #define PIN_CFG_DEFAULT                                        0x00

   /* PIN_CFG 域*/
   #define PIN_CFG_MASK                                        0xFF
   #define PIN_CFG_AIN0                                        0x01
   #define PIN_CFG_AIN1                                        0x02
   #define PIN_CFG_AIN2                                        0x04
   #define PIN_CFG_AIN3                                        0x08
   #define PIN_CFG_AIN4                                        0x10
   #define PIN_CFG_AIN5                                        0x20
   #define PIN_CFG_AIN6                                        0x40
   #define PIN_CFG_AIN7                                        0x80



/*寄存器0x07 (GPIO_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                    GPIO_CFG[7:0]                                                    |
 *|---------------------------------------------------------------- |
 *

   /* GPIO_CFG 寄存器*/
   #define GPIO_CFG_ADDRESS                                     0x07
   #define GPIO_CFG_DEFAULT                                     0x00

   /* GPIO_CFG 字段*/
   #define GPIO_CFG_MASK                                        0xFF
   #define GPIO_CFG_GPO0                                        0x01
   #define GPIO_CFG_GPO1                                        0x02
   #define GPIO_CFG_GPO2                                        0x04
   #define GPIO_CFG_GPO3                                        0x08
   #define GPIO_CFG_GPO4                                        0x10
   #define GPIO_CFG_GPO5                                        0x20
   #define GPIO_CFG_GPO6                                        0x40
   #define GPIO_CFG_GPO7                                        0x80



/*寄存器0x09 (GPO_DRIVE_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                  GPO_DRIVE_CFG[7:0]                                                 |
 *|---------------------------------------------------------------- |
 *

   /* GPO_DRIVE_CFG 寄存器*/
   #define GPO_DRIVE_CFG_ADDRESS                                  0x09
   #define GPO_DRIVE_CFG_DEFAULT                                  0x00

   /* GPO_DRIVE_CFG 字段*/
   #define GPO_DRIVE_CFG_MASK                                     0xFF
   #define GPO_DRIVE_CFG_GPO0                                     0x01
   #define GPO_DRIVE_CFG_GPO1                                     0x02
   #define GPO_DRIVE_CFG_GPO2                                     0x04
   #define GPO_DRIVE_CFG_GPO3                                     0x08
   #define GPO_DRIVE_CFG_GPO4                                     0x10
   #define GPO_DRIVE_CFG_GPO5                                     0x20
   #define GPO_DRIVE_CFG_GPO6                                     0x40
   #define GPO_DRIVE_CFG_GPO7                                     0x80



/*寄存器0x0B (GPO_VALUE)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                    GPO_Value[7:0]                                                   |
 *|---------------------------------------------------------------- |
 *

   /* GPO_VALUE 寄存器*/
   #define GPO_value_address                                     0x0B
   #define GPO_value_default                                     0x00

   /* GPO_VALUE 域*/
   #define GPO_value_mask                                        0xFF
   #define GPO_Value_GPO0_HIGH                                     0x01
   #define GPO_value_GPO1_HIGH                                     0x02
   #define GPO_Value_GPO2_HIGH                                     0x04
   #define GPO_Value_GPO3_HIGH                                     0x08
   #define GPO_Value_GPO4_HIGH                                     0x10
   #define GPO_Value_GPO5_HIGH                                     0x20
   #define GPO_Value_GPO6_HIGH                                     0x40
   #define GPO_Value_GPO7_HIGH                                     0x80



/*寄存器0x0D (GPI_VALUE)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                    GPI_Value[7:0]                                                   |
 *|---------------------------------------------------------------- |
 *

   /* GPI_VALUE 寄存器*/
   #define GPI_value_address                                     0x0D
   #define GPI_value_default                                     0x00

   /* GPI_VALUE 域*/
   #define GPI_value_mask                                        0xFF
   #define GPI_Value_GPI0_HIGH                                     0x01
   #define GPI_value_GPI1_HIGH                                     0x02
   #define GPI_Value_GPI2_HIGH                                     0x04
   #define GPI_value_GPI3_HIGH                                     0x08
   #define GPI_value_GPI4_HIGH                                     0x10
   #define GPI_value_GPI5_HIGH                                     0x20
   #define GPI_value_GPI6_HIGH                                     0x40
   #define GPI_value_GPI7_HIGH                                     0x80



/*寄存器0x10 (SEQUEST_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|               RESERV[2:0]              |  SEQ_START |       RESERV[1:0]       |       SEQ_MODE[1:0]       |
 *|---------------------------------------------------------------- |
 *

   /* SEQUEST_CFG 寄存器*/
   #define SEQUENSE_CFG_ADDRESS                                  0x10
   #define SEQUENSE_CFG_DEFAULT                                  0x00

   /* SEQ_START 字段*/
   #define SEQ_START_MASK                                        0x10
   #define SEQ_START_END                                        默认为0x00 //
   #define SEQ_START_ASSEND                                     0x10

   /* SEQ_MODE 字段*/
   #define SEQ_MODE_MASK                                        0x03
   #define SEQ_MODE_MANUAL                                        默认为0x00 //
   #define SEQ_MODE_AUTO                                        0x01



/*寄存器0x11 (MANUAL_CH_SEL)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                      保留[3:0]                      |                     MANUAL_Chid[3:0]                    |
 *|---------------------------------------------------------------- |
 *

   /* MANUAL_CH_SEL 寄存器*/
   #define MANUAL_CH_SEL_ADDRESS                                  0x11
   #define MANUAL_CH_SEL_DEFAULT                                  0x00

   /* manual_chid 字段*/
   #define MANUAL_Chid_MASK                                     0x0F
   #define MANUAL_Chid_AIN0                                     默认为0x00 //
   #define MANUAL_Chid_AIN1                                     0x01
   #define MANUAL_Chid_AIN2                                     0x02
   #define MANUAL_Chid_AIN3                                     0x03
   #define MANUAL_Chid_AIN4                                     0x04
   #define MANUAL_Chid_AIN5                                     0x05
   #define MANUAL_Chid_AIN6                                     0x06
   #define MANUAL_Chid_AIN7                                     0x07



/*寄存器0x12 (AUTO_SEQ_CH_SEL)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                 AUTO_SEQ_CH_SEL[7:0]                                                |
 *|---------------------------------------------------------------- |
 *

   /* AUTO_SEQ_CH_SEL 寄存器*/
   #define AUTO_SEQ_CH_SEL_ADDRESS                                  0x12
   #define AUTO_SEQ_CH_SEL_DEFAULT                                  0x00

   /* AUTO_SEQ_CH_SEL 字段*/
   #define AUTO_SEQ_CH_SEL_MASK                                  0xFF
   #define AUTO_SEQ_CH_SEL_AIN0                                  0x01
   #define AUTO_SEQ_CH_SEL_AIN1                                  0x02
   #define AUTO_SEQ_CH_SEL_AIN2                                  0x04
   #define AUTO_SEQ_CH_SEL_AIN3                                  0x08
   #define AUTO_SEQ_CH_SEL_AIN4                                  0x10
   #define AUTO_SEQ_CH_SEL_AIN5                                  0x20
   #define AUTO_SEQ_CH_SEL_AIN6                                  0x40
   #define AUTO_SEQ_CH_SEL_AIN7                                  0x80


   #define SLAVE_ADDRESS_TLA                                     (0x13 <<1)

void adc_tla2528_test (void);

#endif /* TLA2528_H_*

b) c 源文件

#include "adc_tla2528.h"
#include "string.h"
#include "USART.h"
#include "i2c.h"

uint8_t rx_buf[100];

void adc_tla2528_test (void)

   unsigned buffchar 1[2];
   buff1[0]= system_status_address;
   buff1[1]= system_status_default;

   unsigned buffchar 2[2];
   buff2[0]= General_CFG_ADDRESS;
   buff2[1]= General_CFG_DEFAULT;

   unsigned buffchar 3[2];
   buff3[0]= DATA_CFG_ADDRESS;
   buff3[1]= DATA_CFG_DEFAULT;

   unsigned buffchar 4[2];
   buff4[0]= OSR_CFG_ADDRESS;
   buff4[1]= OSR_CFG_DEFAULT;

   unsigned buffchar 5[2];
   buff5[0]= OPMODE_CFG_ADDRESS;
   buff5[1]= OPMODE_CFG_DEFAULT;


   unsigned buffchar 6[2];
   buff6[0]= PIN_CFG_ADDRESS;
   buff6[1]= PIN_CFG_DEFAULT;


   unsigned buffchar 7[2];
   buff7[0]= GPIO_CFG_ADDRESS;
   buff7[1]= GPIO_CFG_DEFAULT;


   unsigned buffchar 8[2];
   buff8[0]= GPO_DRIVE_CFG_ADDRESS;
   buff8[1]= GPO_DRIVE_CFG_DEFAULT;


   unsigned buffchar 9[2];
   buff9[0]= GPO_value_address;
   buff9[1]= GPO_value_default;

   unsigned buffchar 10[2];
   buff10[0]= GPI_value_address;
   buff10[1]= GPO_value_default;


   unsigned buffchar 11[2];
   buff11[0]= SEQUEST_CFG_ADDRESS;
   buff11[1]= seque_CFG_DEFAULT;

   unsigned buffchar 12[2];
   buff12[0]= MANUAL_CH_SEL_ADDRESS;
   buff12[1]= MANUAL_CH_SEL_DEFAULT;

   unsigned buffchar 13[2];
   buff13[0]= AUTO_SEQ_CH_SEL_ADDRESS;
   buff13[1]= AUTO_SEQ_CH_SEL_DEFAULT;






      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff1、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff2、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff3、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff4、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff5、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff6、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff7、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff8、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff9、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff10、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff11、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff12、2、100);
      HAL_DELAY (1);
      HAL_I2C_Master_transmit (&hi2c1、slave_address_TLA、(uint8_t *) buff13、2、100);
      HAL_DELAY (1);

      HAL_I2C_Master_Receive (&hi2c1、slave_address_TLA、(uint8_t *) rx_Buf、3、100);

2.通道1配置的代码

  #define system_status_address                                  0x00
   #define SYSTEM_STATUS_DEFAULT                                  0x80

   /* SEQ_STATUS 字段*/
   #define SEQ_STATUS_MASK                                        0x40
   #define SEQ_STATUS_STOPPED                                     默认为0x00   //
   #define SEQ_STATUS_Running                                     0x40

   /* I2C_SPEED 字段*/
   #define I2C_SPEED_MASK                                        0x20
   #define I2C_SPEED_NORMAL                                     默认为0x00   //
   #define I2C_SPEED_HIGH                                        0x20

   /* OSR_DONE 字段*/
   #define OSR_DONE_MASK                                        0x08
   #define OSR_DONE 等待                                     默认为0x00  //
   #define OSR_DONE_COMPLETE                                     0x08

   /* CRC_ERR_FUSE 字段*/
   #define CRC_ERR_FUSE_MASK                                     0x04
   #define CRC_ERR_FUSE_OK                                     默认为0x00  //
   #define CRC_ERR_FUSE_ERROR                                     0x04

   /* CRC_ERR_IN 字段*/
   #define CRC_ERR_IN_MASK                                        0x02
   #define CRC_ERR_IN_OK                                        默认为0x00 //
   #define CRC_ERR_IN_ERROR                                     0x02

   /* BOR 字段*/
   #define BOR_MASK                                           0x01
   #define BOR_OK                                           0x00
   #define BOR_ERROR                                           0x01 //默认值



/*寄存器0x01 (General_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                      RESERV[3:0]                      |    CNVST   |   CH_RST   |     CAL    |     RST    |
 *|---------------------------------------------------------------- |
 *

   /* General_CFG 寄存器*/
   #define General_CFG_ADDRESS                                     0x01
   #define General_CFG_DEFAULT                                     0x00

   /* CNVST 字段*/
   #define CNVST_MASK                                           0x08
   #define CNVST_NORMAL SCL_LEADDETLED_                               默认为0x00 //
   #define CNVST_START_NO_LEVN                                  0x08

   /* CH_RST 字段*/
   #define CH_RST_MASK                                           0x04
   #define CH_RST_NORMAL                                        默认为0x00 //
   #define CH_RST_FORCE_AIN                                     0x04

   /* CAL (校准)字段*/
   #define CAL_MASK                                           0x02
   #define CAL_COMPLETE                                        默认为0x00 //
   #define CAL_START                                           0x02

   /* RST 字段*/
   #define RST_MASK                                           0x01
   #define RST_COMPLETE                                        默认为0x00  //
   #define RST_START                                           0x01



/*寄存器0x02 (DATA_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|   fix_PAT  |  保留  |     append_status[1:0]    |                      保留[3:0]                      |
 *|---------------------------------------------------------------- |
 *

   /* DATA_CFG 寄存器*/
   #define DATA_CFG_ADDRESS                                     0x02
   #define DATA_CFG_DEFAULT                                     0x00

   /* FIX_PAT 字段*/
   #define FIX_PAT_MASK                                        0x80
   #define FIX_PAT_NORMAL                                        默认为0x00 //
   #define FIX_PAT_ENABLE                                        0x80

   /* append_status 字段*/
   #define append_status_mask                                     0x30
   #define append_status_disable                                  默认为0x00  //
   #define append_status_ID                                     0x10
   #define append_status_only                                     0x20



/*寄存器0x03 (OSR_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                              RESERV[4:0]                             |                 OSR[2:0]                 |
 *|---------------------------------------------------------------- |
 *

   /* OSR_CFG 寄存器*/
   #define OSR_CFG_ADDRESS                                        0x03
   #define OSR_CFG_DEFAULT                                        0x00

   /* OSR 字段*/
   #define OSR_MASK                                           0x07
   #define OSR_1                                              默认为0x00   //
   #define OSR_2                                              0x01
   #define OSR_4                                              0x02
   #define OSR_8                                              0x03
   #define OSR_16                                              0x04
   #define OSR_32                                              0x05
   #define OSR_64                                              0x06
   #define OSR_128                                              0x07



/*寄存器0x04 (OPMODE_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|               保留[2:0]              |   OSC_SEL  |                       CLK_DIV[3:0]                      |
 *|---------------------------------------------------------------- |
 *

   /* OPMODE_CFG 寄存器*/
   #define OPMODE_CFG_ADDRESS                                     0x04
   #define OPMODE_CFG_DEFAULT                                     0x00

   /* OSC_SEL 字段*/
   #define OSC_SEL_MASK                                        0x10
   #define OSC_SEL_HIGH_SPEED                                     默认为0x00  //
   #define OSC_SEL_LOW_POWER                                     0x10



/*寄存器0x05 (PIN_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                     PIN_CFG[7:0]                                                    |
 *|---------------------------------------------------------------- |
 *

   /* PIN_CFG 寄存器*/
   #define PIN_CFG_ADDRESS                                        0x05
   #define PIN_CFG_DEFAULT                                        0x00

   /* PIN_CFG 域*/
   #define PIN_CFG_MASK                                        0xFF
   #define PIN_CFG_AIN0                                        0x01
   #define PIN_CFG_AIN1                                        0x02
   #define PIN_CFG_AIN2                                        0x04
   #define PIN_CFG_AIN3                                        0x08
   #define PIN_CFG_AIN4                                        0x10
   #define PIN_CFG_AIN5                                        0x20
   #define PIN_CFG_AIN6                                        0x40
   #define PIN_CFG_AIN7                                        0x80



/*寄存器0x07 (GPIO_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                    GPIO_CFG[7:0]                                                    |
 *|---------------------------------------------------------------- |
 *

   /* GPIO_CFG 寄存器*/
   #define GPIO_CFG_ADDRESS                                     0x07
   #define GPIO_CFG_DEFAULT                                     0x00

   /* GPIO_CFG 字段*/
   #define GPIO_CFG_MASK                                        0xFF
   #define GPIO_CFG_GPO0                                        0x01
   #define GPIO_CFG_GPO1                                        0x02
   #define GPIO_CFG_GPO2                                        0x04
   #define GPIO_CFG_GPO3                                        0x08
   #define GPIO_CFG_GPO4                                        0x10
   #define GPIO_CFG_GPO5                                        0x20
   #define GPIO_CFG_GPO6                                        0x40
   #define GPIO_CFG_GPO7                                        0x80



/*寄存器0x09 (GPO_DRIVE_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                  GPO_DRIVE_CFG[7:0]                                                 |
 *|---------------------------------------------------------------- |
 *

   /* GPO_DRIVE_CFG 寄存器*/
   #define GPO_DRIVE_CFG_ADDRESS                                  0x09
   #define GPO_DRIVE_CFG_DEFAULT                                  0x00

   /* GPO_DRIVE_CFG 字段*/
   #define GPO_DRIVE_CFG_MASK                                     0xFF
   #define GPO_DRIVE_CFG_GPO0                                     0x01
   #define GPO_DRIVE_CFG_GPO1                                     0x02
   #define GPO_DRIVE_CFG_GPO2                                     0x04
   #define GPO_DRIVE_CFG_GPO3                                     0x08
   #define GPO_DRIVE_CFG_GPO4                                     0x10
   #define GPO_DRIVE_CFG_GPO5                                     0x20
   #define GPO_DRIVE_CFG_GPO6                                     0x40
   #define GPO_DRIVE_CFG_GPO7                                     0x80



/*寄存器0x0B (GPO_VALUE)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                    GPO_Value[7:0]                                                   |
 *|---------------------------------------------------------------- |
 *

   /* GPO_VALUE 寄存器*/
   #define GPO_value_address                                     0x0B
   #define GPO_value_default                                     0x00

   /* GPO_VALUE 域*/
   #define GPO_value_mask                                        0xFF
   #define GPO_Value_GPO0_HIGH                                     0x01
   #define GPO_value_GPO1_HIGH                                     0x02
   #define GPO_Value_GPO2_HIGH                                     0x04
   #define GPO_Value_GPO3_HIGH                                     0x08
   #define GPO_Value_GPO4_HIGH                                     0x10
   #define GPO_Value_GPO5_HIGH                                     0x20
   #define GPO_Value_GPO6_HIGH                                     0x40
   #define GPO_Value_GPO7_HIGH                                     0x80



/*寄存器0x0D (GPI_VALUE)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                    GPI_Value[7:0]                                                   |
 *|---------------------------------------------------------------- |
 *

   /* GPI_VALUE 寄存器*/
   #define GPI_value_address                                     0x0D
   #define GPI_value_default                                     0x00

   /* GPI_VALUE 域*/
   #define GPI_value_mask                                        0xFF
   #define GPI_Value_GPI0_HIGH                                     0x01
   #define GPI_value_GPI1_HIGH                                     0x02
   #define GPI_Value_GPI2_HIGH                                     0x04
   #define GPI_value_GPI3_HIGH                                     0x08
   #define GPI_value_GPI4_HIGH                                     0x10
   #define GPI_value_GPI5_HIGH                                     0x20
   #define GPI_value_GPI6_HIGH                                     0x40
   #define GPI_value_GPI7_HIGH                                     0x80



/*寄存器0x10 (SEQUEST_CFG)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|               RESERV[2:0]              |  SEQ_START |       RESERV[1:0]       |       SEQ_MODE[1:0]       |
 *|---------------------------------------------------------------- |
 *

   /* SEQUEST_CFG 寄存器*/
   #define SEQUENSE_CFG_ADDRESS                                  0x10
   #define SEQUENSE_CFG_DEFAULT                                  0x00

   /* SEQ_START 字段*/
   #define SEQ_START_MASK                                        0x10
   #define SEQ_START_END                                        默认为0x00 //
   #define SEQ_START_ASSEND                                     0x10

   /* SEQ_MODE 字段*/
   #define SEQ_MODE_MASK                                        0x03
   #define SEQ_MODE_MANUAL                                        默认为0x00 //
   #define SEQ_MODE_AUTO                                        0x01



/*寄存器0x11 (MANUAL_CH_SEL)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                      保留[3:0]                      |                     MANUAL_Chid[3:0]                    |
 *|---------------------------------------------------------------- |
 *

   /* MANUAL_CH_SEL 寄存器*/
   #define MANUAL_CH_SEL_ADDRESS                                  0x11
   #define MANUAL_CH_SEL_DEFAULT                                  0x01 //通道1已配置

   /* manual_chid 字段*/
   #define MANUAL_Chid_MASK                                     0x0F
   #define MANUAL_Chid_AIN0                                     默认为0x00 //
   #define MANUAL_Chid_AIN1                                     0x01
   #define MANUAL_Chid_AIN2                                     0x02
   #define MANUAL_Chid_AIN3                                     0x03
   #define MANUAL_Chid_AIN4                                     0x04
   #define MANUAL_Chid_AIN5                                     0x05
   #define MANUAL_Chid_AIN6                                     0x06
   #define MANUAL_Chid_AIN7                                     0x07



/*寄存器0x12 (AUTO_SEQ_CH_SEL)定义
 *|---------------------------------------------------------------- |
 *|    位7   |    位6   |    位5   |    位4   |    位3   |    位2   |    位1   |    位0   |
 *|---------------------------------------------------------------- |
 *|                                                 AUTO_SEQ_CH_SEL[7:0]                                                |
 *|---------------------------------------------------------------- |
 *

   /* AUTO_SEQ_CH_SEL 寄存器*/
   #define AUTO_SEQ_CH_SEL_ADDRESS                                  0x12
   #define AUTO_SEQ_CH_SEL_DEFAULT                                  0x00

   /* AUTO_SEQ_CH_SEL 字段*/
   #define AUTO_SEQ_CH_SEL_MASK                                  0xFF
   #define AUTO_SEQ_CH_SEL_AIN0                                  0x01
   #define AUTO_SEQ_CH_SEL_AIN1                                  0x02
   #define AUTO_SEQ_CH_SEL_AIN2                                  0x04
   #define AUTO_SEQ_CH_SEL_AIN3                                  0x08
   #define AUTO_SEQ_CH_SEL_AIN4                                  0x10
   #define AUTO_SEQ_CH_SEL_AIN5                                  0x20
   #define AUTO_SEQ_CH_SEL_AIN6                                  0x40
   #define AUTO_SEQ_CH_SEL_AIN7                                  0x80


   #define SLAVE_ADDRESS_TLA                                     (0x13 <<1)

void adc_tla2528_test (void);

#endif /* TLA2528_H_*

b) C 源代码文件保持不变

请建议

--

Phrutvi

Bharat Electronics Limited

班加罗尔

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Pruthvi、

    浏览代码将需要很长时间、最好能理解您要执行的操作。  

    为了进行调试、我建议使用示波器来比较代码应该执行的操作与数字总线上实际发生的操作。  

    通道的输入信号应为已知的直流值、各通道的直流值不同。 Ex CH0 = GND、CH1 = 1V、依此类推。  

    快速浏览您的代码、我建议一次执行一项操作。 尝试正确读取转换。 然后整合对寄存器的写入和读取、等等。  

    还需要指出 的是、产品文件夹中有一个可用于 TLA2528的头文件-单击此处-

    我假设您是在手动模式下使用器件、 请参阅数据表中的下图。 首先、您需要写入 CHANGE_SEL 寄存器并选择通道1。 我建议在写入该寄存器后对其进行读取、以确保其配置正确。  

    然后您可以进行转换。  您将需要多个帧来转换通道1、然后读取通道1数据。