LMP90100数据采集出现棘手问题
四路差分信号,我使用CH0、CH1、CH2、CH3四个通道读取
现在问题来了,CH_SCAN: 通道扫描模式 (地址 0x1F)通道扫描选择
0x0 (默认值): ScanMode0: 单通道连续转换
0x1: ScanMode1: 一个或多个通道单次扫描
0x2: ScanMode2: 一个或多个通道连续扫描
0x3:ScanMode3: 用熔断电流一个或多个通道连续扫描
我选择0x1,和0x2,用串口把四个通道采集到的数据发到串口助手上,发现不是我想象中的,每个通道采一个数,连采4个,在循环采从CH0到CH3
现在是,采CH0会采几十个数,下来CH1也是几十个数,直到CH3也是几十个数字,而且数量也不是太固定,跟采集速度有关,这样的结果很难判断出来采集的数据是哪个通道采来的,
请弄过这东西的指点一下,我哪个环节出问题了,奋战两天了
问题解决没?碰到类似问题。。。
我用的是根据MSP430的库移植过来的测试软件,用中断置位标志位,主循环里用controlledstream方式读数据,寄存器表里是选择的0x3,不过通道的熔断电流位又没有使能,比较奇怪的用法。起始通道0,结束通道1。
通道0和通道1都是接的0(都是差分,短接),串口收到的数据(通道状态、三个字节数据、CRC)很奇怪:第一次00 00 00 FF FF,第二次FF FF FF 00 00,第三次F6 FF 00 00 00,后续全是00 00 00 00 00,按照数据分析,出现1次通道7数据、1次通道6数据,其他全是通道0数据
在前几天用同样的方式测试过单通道0、0x0(单通道连续采集)的,数据乱七八糟。选择通道0和通道1,用0x3还是数据看着最好的一次。
寄存器表如下:
#define TI_LMP90100_RESETCN_REG_VALUE (0xC3) /* Register and Conversion Reset */ #define TI_LMP90100_SPI_HANDSHAKECN_REG_VALUE (0x01) /* SPI SDO High Z Delayed */ #define TI_LMP90100_SPI_STREAMCN_REG_VALUE (0x84) /* SPI Control Streaming mode: 5 bytes */ #define TI_LMP90100_PWRCN_REG_VALUE (0x00) /* Active Mode */ #define TI_LMP90100_ADC_RESTART_REG_VALUE (0x00) /* Disable restart Conversion */ #define TI_LMP90100_GPIO_DIRCN_REG_VALUE (0x47) /* D6 D0-D3output, D4-D5 inputs */ #define TI_LMP90100_GPIO_DAT_REG_VALUE (0x40) /* Set D6 high, others ignore */ #define TI_LMP90100_BGCALCN_REG_VALUE (0x00) /* Background Calibration OFF */ #define TI_LMP90100_SPI_DRDYBCN_REG_VALUE (0x83) /* Enable DRDYB on D6, bits 0 & 1 must be 1, others default */ #define TI_LMP90100_ADC_AUXCN_REG_VALUE (0x20) /* bypass external clock detection, internal clock, select 0uA RTD current */ #define TI_LMP90100_SPI_CRC_CN_REG_VALUE (0x14) /* enable CRC, Bit 3 must be 0, DRDYB is deasserted after CRC is read */ #define TI_LMP90100_SENDIAG_THLDH_REG_VALUE (0x00) /* Sensor Diagnostic Threshold High */ #define TI_LMP90100_SENDIAG_THLDL_REG_VALUE (0x00) /* Sensor Diagnostic Threshold Low */ #define TI_LMP90100_SCALCN_REG_VALUE (0x00) /* System Calibration Control Normal Mode */ #define TI_LMP90100_ADC_DONE_REG_VALUE (0xFF) /* ADC Data unAvailable */ #define TI_LMP90100_SENDIAG_FLAGS_REG_VALUE (0x00) /* Sensor Diagnostic Flags - status output */ #define TI_LMP90100_ADC_DOUT2_REG_VALUE (0x00) /* ADC Conversion Data 2 */ #define TI_LMP90100_ADC_DOUT1_REG_VALUE (0x00) /* ADC Conversion Data 1 */ #define TI_LMP90100_ADC_DOUT0_REG_VALUE (0x00) /* ADC Conversion Data 0 */ #define TI_LMP90100_SPI_CRC_DAT_REG_VALUE (0xFF) /* Reset CRC Data */ #define TI_LMP90100_CH_STS_REG_VALUE (0x00) /* Channel Status */ #define TI_LMP90100_CH_SCAN_REG_VALUE (0xC8) /* Multiple Channel Continuous Scan: Channel 0 & 1*/ #define TI_LMP90100_CH0_INPUTCN_REG_VALUE (0x01) /* diable sensor diagnostics, default ref, vinp 0 vinn 1 */ #define TI_LMP90100_CH0_CONFIG_REG_VALUE (0x40) /* CH0 Configuratio: 26.83SPS, FGA off, buffer in signal path*/ #define TI_LMP90100_CH1_INPUTCN_REG_VALUE (0x13) /* disable sensor diagnostics, default ref, vinp 2 vinn 3 */ #define TI_LMP90100_CH1_CONFIG_REG_VALUE (0x40) /* CH1 config: 26.835SPS, FGA off, buffer in signal path */ #define TI_LMP90100_CH2_INPUTCN_REG_VALUE (0x25) /* disable sensor diagnostics, default ref, vinp 4 vinn 5 */ #define TI_LMP90100_CH2_CONFIG_REG_VALUE (0x70) /* 214.65SPS, FGA off, buffer in signal path */ #define TI_LMP90100_CH3_INPUTCN_REG_VALUE (0x37) /* disable sensor diagnostics, default ref, vinp 6 vinn 7 */ #define TI_LMP90100_CH3_CONFIG_REG_VALUE (0x70) /* 214.65SPS, FGA off, buffer in signal path */ #define TI_LMP90100_CH4_INPUTCN_REG_VALUE (0x01) /* disable sensor diagnostics, default ref, vinp 2 vinn 3 */ #define TI_LMP90100_CH4_CONFIG_REG_VALUE (0x70) /* 214.65SPS, FGA off, buffer in signal path */ #define TI_LMP90100_CH5_INPUTCN_REG_VALUE (0x13) /* disable sensor diagnostics, default ref, vinp 4 vinn 5 */ #define TI_LMP90100_CH5_CONFIG_REG_VALUE (0x70) /* 214.65SPS, FGA off, buffer in signal path */ #define TI_LMP90100_CH6_INPUTCN_REG_VALUE (0x25) /* disable sensor diagnostics, default ref, vinp 6 vinn 7 */ #define TI_LMP90100_CH6_CONFIG_REG_VALUE (0x70) /* 214.65SPS, FGA off, buffer in signal path */ #define TI_LMP90100_CH0_SCAL_OFFSET2_REG_VALUE (0x00) /* CH0 System Calibration Offset Coefficient [23:16] */ #define TI_LMP90100_CH0_SCAL_OFFSET1_REG_VALUE (0x00) /* CH0 System Calibration Offset Coefficient [15:8] */ #define TI_LMP90100_CH0_SCAL_OFFSET0_REG_VALUE (0x00) /* CH0 System Calibration Offset Coefficient [7:0] */ #define TI_LMP90100_CH0_SCAL_GAIN2_REG_VALUE (0x80) /* CH0 System Calibration Gain Coefficient [23:16] */ #define TI_LMP90100_CH0_SCAL_GAIN1_REG_VALUE (0x00) /* CH0 System Calibration Gain Coefficient [15:8] */ #define TI_LMP90100_CH0_SCAL_GAIN0_REG_VALUE (0x00) /* CH0 System Calibration Gain Coefficient [7:0] */ #define TI_LMP90100_CH0_SCAL_SCALING_REG_VALUE (0x00) /* CH0 System Calibration Scaling Coefficient */ #define TI_LMP90100_CH0_SCAL_BITS_SELECTOR_REG_VALUE (0x00) /* CH0 System Calibration Bits Selector */ #define TI_LMP90100_CH1_SCAL_OFFSET2_REG_VALUE (0x00) /* CH1 System Calibration Offset Coefficient [23:16] */ #define TI_LMP90100_CH1_SCAL_OFFSET1_REG_VALUE (0x00) /* CH1 System Calibration Offset Coefficient [15:8] */ #define TI_LMP90100_CH1_SCAL_OFFSET0_REG_VALUE (0x00) /* CH1 System Calibration Offset Coefficient [7:0] */ #define TI_LMP90100_CH1_SCAL_GAIN2_REG_VALUE (0x80) /* CH1 System Calibration Gain Coefficient [23:16] */ #define TI_LMP90100_CH1_SCAL_GAIN1_REG_VALUE (0x00) /* CH1 System Calibration Gain Coefficient [15:8] */ #define TI_LMP90100_CH1_SCAL_GAIN0_REG_VALUE (0x00) /* CH1 System Calibration Gain Coefficient [7:0] */ #define TI_LMP90100_CH1_SCAL_SCALING_REG_VALUE (0x00) /* CH1 System Calibration Scaling Coefficient */ #define TI_LMP90100_CH1_SCAL_BITS_SELECTOR_REG_VALUE (0x00) /* CH1 System Calibration Bits Selector */ #define TI_LMP90100_CH2_SCAL_OFFSET2_REG_VALUE (0x00) /* CH2 System Calibration Offset Coefficient [23:16] */ #define TI_LMP90100_CH2_SCAL_OFFSET1_REG_VALUE (0x00) /* CH2 System Calibration Offset Coefficient [15:8] */ #define TI_LMP90100_CH2_SCAL_OFFSET0_REG_VALUE (0x00) /* CH2 System Calibration Offset Coefficient [7:0] */ #define TI_LMP90100_CH2_SCAL_GAIN2_REG_VALUE (0x80) /* CH2 System Calibration Gain Coefficient [23:16] */ #define TI_LMP90100_CH2_SCAL_GAIN1_REG_VALUE (0x00) /* CH2 System Calibration Gain Coefficient [15:8] */ #define TI_LMP90100_CH2_SCAL_GAIN0_REG_VALUE (0x00) /* CH2 System Calibration Gain Coefficient [7:0] */ #define TI_LMP90100_CH2_SCAL_SCALING_REG_VALUE (0x00) /* CH2 System Calibration Scaling Coefficient */ #define TI_LMP90100_CH2_SCAL_BITS_SELECTOR_REG_VALUE (0x00) /* CH2 System Calibration Bits Selector */ #define TI_LMP90100_CH3_SCAL_OFFSET2_REG_VALUE (0x00) /* CH3 System Calibration Offset Coefficient [23:16] */ #define TI_LMP90100_CH3_SCAL_OFFSET1_REG_VALUE (0x00) /* CH3 System Calibration Offset Coefficient [15:8] */ #define TI_LMP90100_CH3_SCAL_OFFSET0_REG_VALUE (0x00) /* CH3 System Calibration Offset Coefficient [7:0] */ #define TI_LMP90100_CH3_SCAL_GAIN2_REG_VALUE (0x80) /* CH3 System Calibration Gain Coefficient [23:16] */ #define TI_LMP90100_CH3_SCAL_GAIN1_REG_VALUE (0x00) /* CH3 System Calibration Gain Coefficient [15:8] */ #define TI_LMP90100_CH3_SCAL_GAIN0_REG_VALUE (0x00) /* CH3 System Calibration Gain Coefficient [7:0] */ #define TI_LMP90100_CH3_SCAL_SCALING_REG_VALUE (0x00) /* CH3 System Calibration Scaling Coefficient */ #define TI_LMP90100_CH3_SCAL_BITS_SELECTOR_REG_VALUE (0x00) /* CH3 System Calibration Bits Selector */