2025-05-05 9:42 PM - edited 2025-05-06 12:28 AM
In my design, I want to drive a dac with octospi.
I need to transmit data via the interface in DAC data frame without any instruction and address.
like:
*(__IO uint8_t*)&OCTOSPI1->DR = data[i];
void OCTOSPI1_Init(void)
{
OCTOSPI1->CR &= ~OCTOSPI_CR_EN;
while ((OCTOSPI1->CR & OCTOSPI_CR_EN) != 0);
OCTOSPI1->DCR1 = (0 << OCTOSPI_DCR1_CSHT_Pos) | (2 << OCTOSPI_DCR1_DEVSIZE_Pos);
OCTOSPI1->CCR = (0b11 << OCTOSPI_CCR_DMODE_Pos); // Data on 4 lines
OCTOSPI1->DCR2 = 3; // prescaler = 4
OCTOSPI1->DLR = 2; // 2
OCTOSPI1->CR |= OCTOSPI_CR_EN;
MODIFY_REG(OCTOSPI1->CR, OCTOSPI_CR_FMODE, 0x00000000);
}
void OCTOSPI1_WriteData(uint8_t* data, uint32_t length)
{
for (uint32_t i = 0; i < length; i++) {
while (!(OCTOSPI1->SR & OCTOSPI_SR_FTF)); // wait for FIFO available
*(__IO uint8_t*)&OCTOSPI1->DR = data[i];
}
// wait for transmission completion
while (!(OCTOSPI1->SR & OCTOSPI_SR_TCF));
OCTOSPI1->FCR |= OCTOSPI_FCR_CTCF; // clear transmission completion flag
}
The operation above will block the mcu totally.
Is it possible to do that by octospi and how to configure?
2025-05-06 12:38 AM
I suspect you can do that, the different phases are more of a HAL manifestation. Check library source vs references manual
2025-05-06 2:15 AM - edited 2025-05-06 2:20 AM
it’ better to know how the hardware works. Only to read the reference manual doesn’t help, and going through various register combinations is also impossible.