AFE4400
请教一下AFE4400血氧模块的AFE_PDNZ管脚是输入口还是输出口,它的作用是什么样的?是不是寄存器配置好以后,期间会自动工作?
是输入口,控制芯片进入低功耗模式,AFE-only power-down input; active low. Can be connected to the port pin of an external microcontroller.
配置好后,芯片会自动执行亮灯采样,然后采集数据。
我现在电路焊好了,程序也写好了,但是程序烧进去,感觉寄存器没有配置成功,没有任何现象,电路板检查唯一的现象是CLKOUT的输出是正常的4Mhz,不知道问题是什么。
#include <msp430F5528.h>
unsigned long LL;
unsigned long AFE44xx_Default_Register_Settings[49] = {
//Reg0: CONTROL0: CONTROL REGISTER 0
0x00000,
//* =======================500Hz================================= //
// //Reg1:REDSTARTCOUNT: SAMPLE RED START COUNT
// 6000,
// //Reg2:REDENDCOUNT: SAMPLE RED END COUNT
// 7599,
// //Reg3:REDLEDSTARTCOUNT: RED LED START COUNT
// 6000,
// //Reg4:REDLEDENDCOUNT: RED LED END COUNT
// 7599,
// //Reg5:AMBREDSTARTCOUNT: SAMPLE AMBIENT RED START COUNT
// 0000,
// //Reg6:AMBREDENDCOUNT: SAMPLE AMBIENT RED END COUNT
// 1599,
// //Reg7:IRSTARTCOUNT: SAMPLE IR START COUNT
// 2000,
// //Reg8:IRENDCOUNT: SAMPLE IR END COUNT
// 3599,
// //Reg9:IRLEDSTARTCOUNT: IR LED START COUNT
// 2000,
// //Reg10:IRLEDENDCOUNT: IR LED END COUNT
// 3599,
// //Reg11:AMBIRSTARTCOUNT: SAMPLE AMBIENT IR START COUNT
// 4000,
// //Reg12:AMBIRENDCOUNT: SAMPLE AMBIENT IR END COUNT
// 5599,
// //Reg13:REDCONVSTART: REDCONVST
// 2,
// //Reg14:REDCONVEND: RED CONVERT END COUNT
// 1999,
// //Reg15:AMBREDCONVSTART: RED AMBIENT CONVERT START COUNT
// 2002,
// //Reg16:AMBREDCONVEND: RED AMBIENT CONVERT END COUNT
// 3999,
// //Reg17:IRCONVSTART: IR CONVERT START COUNT
// 4002,
// //Reg18:IRCONVEND: IR CONVERT END COUNT
// 5999,
// //Reg19:AMBIRCONVSTART: IR AMBIENT CONVERT START COUNT
// 6002,
// //Reg20:AMBIRCONVEND: IR AMBIENT CONVERT END COUNT
// 7999,
// //Reg21:ADCRESETSTCOUNT0: ADC RESET 0 START COUNT
// 0,
// //Reg22:ADCRESETENDCOUNT0: ADC RESET 0 END COUNT
// 0,
// //Reg23:ADCRESETSTCOUNT1: ADC RESET 1 START COUNT
// 2000,
// //Reg24:ADCRESETENDCOUNT1: ADC RESET 1 END COUNT
// 2000,
// //Reg25:ADCRESETENDCOUNT2: ADC RESET 2 START COUNT
// 4000,
// //Reg26:ADCRESETENDCOUNT2: ADC RESET 2 END COUNT
// 4000,
// //Reg27:ADCRESETENDCOUNT3: ADC RESET 3 START COUNT
// 6000,
// //Reg28:ADCRESETENDCOUNT3: ADC RESET 3 END COUNT
// 6000,
// //Reg29:PRPCOUNT: PULSE REPETITION PERIOD COUNT
// 7999,
/*=======================80Hz======================================*/
//Reg1:REDSTARTCOUNT: SAMPLE RED START COUNT
37500,
//Reg2:REDENDCOUNT: SAMPLE RED END COUNT
49999,
//Reg3:REDLEDSTARTCOUNT: RED LED START COUNT
37500,
//Reg4:REDLEDENDCOUNT: RED LED END COUNT
49999,
//Reg5:AMBREDSTARTCOUNT: SAMPLE AMBIENT RED START COUNT
0000,
//Reg6:AMBREDENDCOUNT: SAMPLE AMBIENT RED END COUNT
12499,
//Reg7:IRSTARTCOUNT: SAMPLE IR START COUNT
12500,
//Reg8:IRENDCOUNT: SAMPLE IR END COUNT
24999,
//Reg9:IRLEDSTARTCOUNT: IR LED START COUNT
12500,
//Reg10:IRLEDENDCOUNT: IR LED END COUNT
24999,
//Reg11:AMBIRSTARTCOUNT: SAMPLE AMBIENT IR START COUNT
25000,
//Reg12:AMBIRENDCOUNT: SAMPLE AMBIENT IR END COUNT
37499,
//Reg13:REDCONVSTART: REDCONVST
2,
//Reg14:REDCONVEND: RED CONVERT END COUNT
12499,
//Reg15:AMBREDCONVSTART: RED AMBIENT CONVERT START COUNT
12502,
//Reg16:AMBREDCONVEND: RED AMBIENT CONVERT END COUNT
24999,
//Reg17:IRCONVSTART: IR CONVERT START COUNT
25002,
//Reg18:IRCONVEND: IR CONVERT END COUNT
37499,
//Reg19:AMBIRCONVSTART: IR AMBIENT CONVERT START COUNT
37502,
//Reg20:AMBIRCONVEND: IR AMBIENT CONVERT END COUNT
49999,
//Reg21:ADCRESETSTCOUNT0: ADC RESET 0 START COUNT
0,
//Reg22:ADCRESETENDCOUNT0: ADC RESET 0 END COUNT
0,
//Reg23:ADCRESETSTCOUNT1: ADC RESET 1 START COUNT
12500,
//Reg24:ADCRESETENDCOUNT1: ADC RESET 1 END COUNT
12500,
//Reg25:ADCRESETENDCOUNT2: ADC RESET 2 START COUNT
25000,
//Reg26:ADCRESETENDCOUNT2: ADC RESET 2 END COUNT
25000,
//Reg27:ADCRESETENDCOUNT3: ADC RESET 3 START COUNT
37500,
//Reg28:ADCRESETENDCOUNT3: ADC RESET 3 END COUNT
37500,
//Reg29:PRPCOUNT: PULSE REPETITION PERIOD COUNT
49999,
/*=======================62.5Hz======================================*/
// //Reg1:REDSTARTCOUNT: SAMPLE RED START COUNT
// 0x0BB80,
// //Reg2:REDENDCOUNT: SAMPLE RED END COUNT
// 0x0F9FE,
// //Reg3:REDLEDSTARTCOUNT: RED LED START COUNT
// 0x0BB80,
// //Reg4:REDLEDENDCOUNT: RED LED END COUNT
// 0x0F9FF,
// //Reg5:AMBREDSTARTCOUNT: SAMPLE AMBIENT RED START COUNT
// 0000,
// //Reg6:AMBREDENDCOUNT: SAMPLE AMBIENT RED END COUNT
// 0x03E7E,
// //Reg7:IRSTARTCOUNT: SAMPLE IR START COUNT
// 0x03E80,
// //Reg8:IRENDCOUNT: SAMPLE IR END COUNT
// 0x07CFE,
// //Reg9:IRLEDSTARTCOUNT: IR LED START COUNT
// 0x03E80,
// //Reg10:IRLEDENDCOUNT: IR LED END COUNT
// 0x07CFF,
// //Reg11:AMBIRSTARTCOUNT: SAMPLE AMBIENT IR START COUNT
// 0x07D00,
// //Reg12:AMBIRENDCOUNT: SAMPLE AMBIENT IR END COUNT
// 0x0BB7E,
// //Reg13:REDCONVSTART: REDCONVST
// 0x00002,
// //Reg14:REDCONVEND: RED CONVERT END COUNT
// 0x03E7F,
// //Reg15:AMBREDCONVSTART: RED AMBIENT CONVERT START COUNT
// 0x03E82,
// //Reg16:AMBREDCONVEND: RED AMBIENT CONVERT END COUNT
// 0x07CFF,
// //Reg17:IRCONVSTART: IR CONVERT START COUNT
// 0x07D02,
// //Reg18:IRCONVEND: IR CONVERT END COUNT
// 0x0BB7F,
// //Reg19:AMBIRCONVSTART: IR AMBIENT CONVERT START COUNT
// 0x0BB82,
// //Reg20:AMBIRCONVEND: IR AMBIENT CONVERT END COUNT
// 0x0F9FF,
// //Reg21:ADCRESETSTCOUNT0: ADC RESET 0 START COUNT
// 0,
// //Reg22:ADCRESETENDCOUNT0: ADC RESET 0 END COUNT
// 0,
// //Reg23:ADCRESETSTCOUNT1: ADC RESET 1 START COUNT
// 0x03E80,
// //Reg24:ADCRESETENDCOUNT1: ADC RESET 1 END COUNT
// 0x03E80,
// //Reg25:ADCRESETENDCOUNT2: ADC RESET 2 START COUNT
// 0x07D00,
// //Reg26:ADCRESETENDCOUNT2: ADC RESET 2 END COUNT
// 0x07D00,
// //Reg27:ADCRESETENDCOUNT3: ADC RESET 3 START COUNT
// 0x0BB80,
// //Reg28:ADCRESETENDCOUNT3: ADC RESET 3 END COUNT
// 0x0BB80,
// //Reg29:PRPCOUNT: PULSE REPETITION PERIOD COUNT
// 0x0F9FF,
//Reg30:CONTROL1: CONTROL REGISTER 1
0x00107, //timer enabled, averages=3, RED and IR LED pulse ON PD_ALM AND LED_ALM pins
//Reg31:?: ??
0x00000,
//Reg32:TIAGAIN: TRANS IMPEDANCE AMPLIFIER GAIN SETTING REGISTER
0x00000,
//Reg33:TIA_AMB_GAIN: TRANS IMPEDANCE AAMPLIFIER AND AMBIENT CANELLATION STAGE GAIN
0x00000,
//Reg34:LEDCNTRL: LED CONTROL REGISTER
//0x11414, // 初始电流 Red:3.90625mA, IR:3.90625mA
0x12020,
//Reg35:CONTROL2: CONTROL REGISTER 2
//0x00000, //bit 9
0x20300, // external 8MHz clock bit9=1,**********************************
//Reg36:?: ??
0x00000,
//Reg37:?: ??
0x00000,
//Reg38:?: ??
0x00000,
//Reg39:?: ??
0x00000,
//Reg40:: ??
0x00000,
//Reg41:ALARM: ??
0x00000,
//Reg42:REDVALUE: RED DIGITAL SAMPLE VALUE
0x00000,
//Reg43:AMBREDVALUE: Ambient RED Digital Sample Value
0x00000,
//Reg44:IRVALUE: IR Digital Sample Value
0x00000,
//Reg45:AMBIRVALUE: Ambient IR Digital Sample Value
0x00000,
//Reg46:RED-AMBREDVALUE: RED-AMBIENT RED DIGITAL SAMPLE VALUE
0x00000,
//Reg47:IR-AMBIRVALUE: IR-AMBIENT IR DIGITAL SAMPLE VALUE
0x00000,
//Reg48:DIGNOSTICS: DIAGNOSTICS FLAGS REGISTER
0x00000
};
//初始化串口
void UART()
{
P4SEL = BIT4+BIT5; // P3.4,5 = USCI_A0 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 0x36; // 1MHz 9600 (see User's Guide)
UCA1BR1 = 0; // 1MHz 9600
UCA1MCTL = UCBRS_5 + UCBRF_0; // Modln UCBRSx=0, UCBRFx=0,
// over sampling
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE &= ~ UCRXIE; // disable USCI_A0 RX interrupt
}
void delay()
{
int i;
for(i=0;i<10;i++);
}
void Set_GPIO(void)
{
P3DIR |= 0x18; //p3.3(REST),p3.4(PDNZ)定义为输出口
P3OUT |= 0x18;
P4DIR |= 0x01; //p4.0(CS)定义为输出口
P2REN |=BIT2; //P2.2产生中断
P2OUT |=BIT2;
P2IES |=BIT2;
P2IFG &= ~BIT2;
P2IE |=BIT2;
}
void Spi_Initial()
{
P4SEL |=BIT1+BIT2+BIT3; //P3.0.1.2设置成SPI通信模式
UCB1CTL1 |=UCSWRST; //软件复位SPI模块
UCB1CTL0 |=UCMST+UCSYNC+UCMSB; // 主机模式,同步模式,高位在前,不活动状态不低电平
UCB1CTL1 |=UCSSEL_2; //时钟选择为SMCLK
UCB1BR0 = 0X02;
UCB1BR1 = 0X00; //时钟信号分频
UCB1CTL1 &= ~UCSWRST; //完成寄存器的配置
UCB1IE |= UCRXIE+UCTXIE; //使能USCI_B0接收中断
}
void AFE44xx_Reg_Write (unsigned char reg_address, unsigned long data)
{
unsigned char dummy_rx;
//Set Control0 - Disable SPI Read bit
//Write to register - byte wise transfer, 8-Bit transfers
P4OUT&= ~0x01; // SEN LOW FOR TRANSMISSION.
// Loop unrolling for machine cycle optimization
UCB1TXBUF = 0; // Send the first byte to the TX Buffer: Address of register
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 0; // Send the second byte to the TX Buffer: Data[23:16]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 0; // Send the third byte to the TX Buffer: Data[15:8]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 0; // Send the first byte to the TX Buffer: Data[7:0]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
P4OUT|=0x01; // SEN HIGH
//Write to register - byte wise transfer, 8-Bit transfers
P4OUT&= ~0x01; // SEN LOW FOR TRANSMISSION.
// Loop unrolling for machine cycle optimization
UCB1TXBUF = reg_address; // Send the first byte to the TX Buffer: Address of register
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = (unsigned char)(data >>16); // Send the second byte to the TX Buffer: Data[23:16]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = (unsigned char)(((data & 0x00FFFF) >>8)); // Send the third byte to the TX Buffer: Data[15:8]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = (unsigned char)(((data & 0x0000FF))); // Send the first byte to the TX Buffer: Data[7:0]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
P4OUT|=0x01; // SEN HIGH
}
void AFE44xx_Default_Reg_Init(void)
{
unsigned char Reg_Init_i;
for ( Reg_Init_i = 0; Reg_Init_i < 49; Reg_Init_i++)
{
AFE44xx_Reg_Write(Reg_Init_i, AFE44xx_Default_Register_Settings[Reg_Init_i]);
}
}
unsigned long AFE44xx_Reg_Read(unsigned char Reg_address)
{
unsigned char dummy_rx;
unsigned long retVal, SPI_Rx_buf[10];
retVal = 0;
//Read register and set bit 0 to 1, to enable read
//Set Control0 - Enable SPI Read bit
P4OUT&= ~0x01; // SEN LOW FOR TRANSMISSION.
// Loop unrolling for machine cycle optimization
UCB1TXBUF = 0; // Send the first byte to the TX Buffer: Address of register
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 0; // Send the second byte to the TX Buffer: Data[23:16]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 0; // Send the third byte to the TX Buffer: Data[15:8]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 1; // Send the first byte to the TX Buffer: Data[7:0]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
P4OUT|=0x01; // set HIGH at end of transmission
//Read from register - byte wise transfer, 8-Bit transfers
P4OUT&= ~0x01; // SEN LOW FOR TRANSMISSION.
// Loop unrolling for machine cycle optimization
UCB1TXBUF = Reg_address; // Send the first byte to the TX Buffer: Address of register
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
SPI_Rx_buf[0] = UCB1RXBUF; // Read Rx buf
UCB1TXBUF = 0; // Send the second byte to the TX Buffer: dummy data
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
SPI_Rx_buf[1] = UCB1RXBUF; // Read Rx buf: Data[23:16]
UCB1TXBUF = 0; // Send the third byte to the TX Buffer: dummy data
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
SPI_Rx_buf[2] = UCB1RXBUF; // Read Rx buf: Data[15:8]
UCB1TXBUF = 0; // Send the first byte to the TX Buffer: dummy data
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
SPI_Rx_buf[3] = UCB1RXBUF; // Read Rx buf: Data[7:0]
P4OUT|=0x01; // set HIGH at end of transmission
//Set Control0 - Disable SPI Read bit
//Write to register - byte wise transfer, 8-Bit transfers
P4OUT&= ~0x01; // SEN LOW FOR TRANSMISSION.
// Loop unrolling for machine cycle optimization
UCB1TXBUF = 0; // Send the first byte to the TX Buffer: Address of register
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 0; // Send the second byte to the TX Buffer: Data[23:16]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 0; // Send the third byte to the TX Buffer: Data[15:8]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
UCB1TXBUF = 0; // Send the first byte to the TX Buffer: Data[7:0]
while ( (UCB1STAT & UCBUSY) ); // USCI_B1 TX buffer ready?
dummy_rx = UCB1RXBUF; // Dummy Read Rx buf
P4OUT|=0x01; // set HIGH at end of transmission
retVal = (SPI_Rx_buf[1]<<16)|(SPI_Rx_buf[2]<<8)|(SPI_Rx_buf[3]);
return retVal;
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
Set_GPIO();
UART();
Spi_Initial();
// _BIS_SR(GIE); //进入LPM3模式/ 开中断允许
P2IFG &= ~BIT2; // P2.2 IFG cleared
P2IE |= BIT2; // P2.2 interrupt enabled
AFE44xx_Default_Reg_Init();
while(1)
{
LL=AFE44xx_Reg_Read(46);
}
}
这是我的程序
TI的员工基本很少回答问题,一般问题就这么不了了之,无语的售后