cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to drive peripheral devices with octospi?

dh_leslie
Associate II

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?

2 REPLIES 2

I suspect you can do that, the different phases are more of a HAL manifestation. Check library source vs references manual 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.