Hi, currently I am trying to write my own driver on stm32 nuleo-144 F303ZE for dwm1000 using PlatofromIO mbed framework. I have successfully write code for simple read/write register however when trying to activate LDELOAD (2D:06) I realize that I can’t change the bit from 0 to 1. I have done all the step in Table 4 according to the user manual, here is my code:
void initializeLDE()
{
cs = 0;
spi.write((PMSC_CTRL0 & 0x3F) | 0xC0); // Write command with register address
spi.write(0x00); // Write the sub-index
spi.write(0x01);
spi.write(0x0301);
cs = 1;
writeSubRegister(OTP_IF, OTP_CTRL, 2, 0x8000);
wait_us(150);
writeSubRegister(PMSC_CTRL0, PMSC_CTRL0_SUB, 2, 0x0200);
}
code for writing to register:
void writeSubRegister(char reg, char subIndex, int length, uint32_t data)
{
cs = 0;
spi.write((reg & 0x3F) | 0xC0); // Clear bit 6, set bits 7 and 6 to 1 (write operation, sub-index present)
spi.write(subIndex); // Write the sub-index
for (int i = 0; i < length; i++)
{
spi.write((data >> (8 * i)) & 0xFF); // Write each byte of the data
}
cs = 1;
}
My SPI config:
void initSPI()
{
spi.format(8, 0); // Set SPI format to 8 bits, mode 0 (CPOL=0, CPHA=0)
spi.frequency(1000000); // Set SPI frequency to 1MHz
readRegister(0x00, 4); // Read the device ID to wake up the DW1000
}
Result:
000000000000000
When I try writing 0xFFFF to 0x2D:06 (OTP_CTRL):
0111111111111001
PS: I have read User Manual v2.18v LDELOAD , but nothing helped