max35101 SPI Communication Issue.

Thread Starter

SajidAhmed

Joined Sep 15, 2020
3
i have tried Communicating max35101 with stm32, but didn't revceive any data from IC and The MAX35101 SPI peripheral operates in SPI mode 1, which means that the SCLK circuit idles in a low state and that data is expected to change on the rising edge of the clock and be sampled on the falling edge. In stm32 i have config SPI as mode1 (ie. CPOL=0,CPHA=1). and also tried with different modes but i unable to communicate with MAX ic.
I would like a opinion on this.
thanks
 

mckenney

Joined Nov 10, 2018
125
What have you tried so far? And what result(s) did you get?

I suggest you start by reading the TOF1 register (0xB8), since that's the only register with a non-zero startup value [Ref data sheet (19-6830, Rev 1) Table 10].
 

Thread Starter

SajidAhmed

Joined Sep 15, 2020
3
I have tried reading RTC seconds Reg. (0x30), but I'm always getting 0x0000 for this reg.
as u suggested to read TOF1 Reg. (0xB0), but same results 0x0000 getting.
I think I have to see all the connections and SPI Config. in STM32.
can u suggest me the SPI Byte read write Function. Now I'm using this.

Code:
uint8_t SPIx_Transfer(uint8_t data)
{
    // Write data to be transmitted to the SPI data register
    SPIx->DR = data;
    // Wait until transmit complete
//        printf("Wait until transmit complete...\r\n");
    while (!(SPIx->SR & (SPI_SR_TXE)));
    // Wait until receive complete
    while (!(SPIx->SR & (SPI_SR_RXNE)));
    // Wait until SPI is not busy anymore
    while (SPIx->SR & (SPI_SR_BSY));
    // Return received data from SPI data register
    return SPIx->DR;
}
 

mckenney

Joined Nov 10, 2018
125
I have tried reading RTC seconds Reg. (0x30), but I'm always getting 0x0000 for this reg.
as u suggested to read TOF1 Reg. (0xB0), but same results 0x0000 getting.
This function is OK; the TXE check should precede the write to DR, but that's not what's causing you trouble.

How are you calling this function? Are you following the sequence in data sheet Figs 14-17?

The high order bit of the opcode is (evidently) the "Read request" bit, so if you send 0x30 that's a Write.
 

Thread Starter

SajidAhmed

Joined Sep 15, 2020
3
Yes, Now I able to read 0x30 and also 0xb0 reg.
actually my communication wires was too long and some female jumpers was very lose. i think thats the problem.
and thank you sir, for help me to solve this issues.
 
Top