Hi guys! A few month ago I created a post before starting to use Honeywell's HIH9131 sensor (https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/510084 ). I started playing with this guy this week and I can't really make it work, and I need it in order to measure relative humidity and temperature. First of all here's the schematic:
The top part is in one board and the bottom one is another board. I'm using TM4C123GH6PM with TIvaWare, and Coocox with GCC to program. I'm also attaching sensor's datasheet and SPI comms app note to understand how it works.
So, how I understood it works:
- 8 bit read to wake it up (I send a dummy byte) and provide clock
- Read and discard data
- Wait 36.56mS for conversion
- Read 4 bytes providing clock (I send 4 dummy bytes)
Here's my code:
int main(void)
{
int txdata=0xAA;
int HR_LSB = 0;
int HR_MSB = 0;
uint32_t pui32DataRx[2];
//
// Initialization
Initialize();
// PF0 Rx
// PF1 Tx Not used
// PF2 Clk
// PF3 Fss/CS
//
// Enable SSI1
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
SysCtlDelay(10);
// Disabling SSI to configure
SSIDisable(SSI1_BASE);
// Set clock source
SSIClockSourceSet(SSI1_BASE, SSI_CLOCK_SYSTEM);
// GPIO config
GPIOPinConfigure(GPIO_PF2_SSI1CLK);
GPIOPinConfigure(GPIO_PF3_SSI1FSS);
GPIOPinConfigure(GPIO_PF0_SSI1RX);
GPIOPinConfigure(GPIO_PF1_SSI1TX);
GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
// Max clock input is 800kHz
//SSIConfigSetExpClk(SSI1_BASE, (SysCtlClockGet()), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 10000, 8);
SSIConfigSetExpClk(SSI1_BASE, 400000, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000, 16);
// Enable SSI1
SSIEnable(SSI1_BASE);
//
while(1)
{
// TODO: Measurement Request command
SSIDataPutNonBlocking(SSI1_BASE, 0xAA);
SSIDataGet(SSI1_BASE, &txdata);
// TODO: Conversion time: 36.65mS
delayMS(40);
//
// Re-configure for 16 bit
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
SysCtlDelay(10);
SSIDisable(SSI1_BASE);
SSIClockSourceSet(SSI1_BASE, SSI_CLOCK_SYSTEM);
GPIOPinConfigure(GPIO_PF2_SSI1CLK);
GPIOPinConfigure(GPIO_PF3_SSI1FSS);
GPIOPinConfigure(GPIO_PF0_SSI1RX);
GPIOPinConfigure(GPIO_PF1_SSI1TX);
GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
SSIConfigSetExpClk(SSI1_BASE, 400000, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000, 32);
SSIEnable(SSI1_BASE);
// TODO: Data Fetch
SSIDataPutNonBlocking(SSI1_BASE, 0xAAAA);
SSIDataGetNonBlocking(SSI1_BASE, HR_MSB);
SSIDataPutNonBlocking(SSI1_BASE, 0xAAAA);
SSIDataGetNonBlocking(SSI1_BASE, HR_LSB);
delayUS(640);
}
}
I probed clock going to the sensor and I'm getting 100kHz (datasheet says clock's frequency should be between 50 and 800kHz), 8 clock cycles to convert, I wait 40mS and then 16 clock cycles.
I probed Chip Select and I get one in the middle of the reading sequence (I think it is because I am sending two bytes at a time instead of four bytes in a roll):
And when I probe Rx I can see something like the next pic. Data is changing, that's good, but it seems to be repeating two times (Again I think that's because I'm sending two bytes at a time).
The thing is I don't get any read data to HR_MSB or HR_LSB, they are always zero. I already tried everything that came to my head, but I always get the same result. I followed Rx path and it's going from the sensor to microcontrolle's pin, so I didn't see any issue here.
I would appreciate every comment or fresh idea to try and thanks in advance!
Franco.
0160.005 SPI Comms with Digital Humidity_Temp Sensors TN_009071-1-EN_Final_07Jun12.pdf