AnsweredAssumed Answered

I2S problem to change MCU from STM32F107 to STM32F407

Question asked by vendramini.gabriel on Apr 6, 2015
Latest reply on Apr 7, 2015 by vendramini.gabriel
I developed an application using the I2S module on STM32F107VCT6.
I'm using the MikroE compiller and there aren't any library for this. Then I configured each register accordong to the Reference manual (RM0008).

Now I changed the MCU to the STM32F407VET6. I made the hardware changes on some supply pins.
As I saw on its Reference manual (RM0090), the configurations are the same, but the modulo doesn't work.

This is my code (I only added the configuration for PLLI2SN and PLLI2SR registers). If you retire this and use in a STM32F107 MCU, it will work well.
I'm checking the PLLI2S2 clk on MCO2 output pin and it is ok.

//BCK and LRCLK (WS) pins
GPIO_Set_Pin_Mode(&GPIOB_BASE, _GPIO_PINMASK_10 | _GPIO_PINMASK_12, _GPIO_CFG_MODE_OUTPUT | _GPIO_CFG_MODE_ALT_FUNCTION | _GPIO_CFG_SPEED_MAX);

// SD pin
GPIO_Digital_Input(&GPIOC_IDR, _GPIO_PINMASK_3);
    
// MCLK - systemclock
GPIO_Set_Pin_Mode(&GPIOC_BASE, _GPIO_PINMASK_6, _GPIO_CFG_MODE_OUTPUT | _GPIO_CFG_MODE_ALT_FUNCTION | _GPIO_CFG_SPEED_MAX);
    
// SPI2 = 1 (spi2 clock enable)
RCC_APB1ENR.SPI2EN = 1;
    
// PLLI2SN = 258
RCC_PLLI2SCFGR.PLLI2SNx0 = 0;
RCC_PLLI2SCFGR.PLLI2SNx1 = 1;
RCC_PLLI2SCFGR.PLLI2SNx2 = 0;
RCC_PLLI2SCFGR.PLLI2SNx3 = 0;
RCC_PLLI2SCFGR.PLLI2SNx4 = 0;
RCC_PLLI2SCFGR.PLLI2SNx5 = 0;
RCC_PLLI2SCFGR.PLLI2SNx6 = 0;
RCC_PLLI2SCFGR.PLLI2SNx7 = 0;
RCC_PLLI2SCFGR.PLLI2SNx8 = 1;

// PLLI2SR = 3
    RCC_PLLI2SCFGR.PLLI2SRx0 = 1;
    RCC_PLLI2SCFGR.PLLI2SRx1 = 1;
    RCC_PLLI2SCFGR.PLLI2SRx2 = 0;

    // I2SDIV = 3
    SPI2_I2SPR.I2SDIV0 = 1;
    SPI2_I2SPR.I2SDIV1 = 1;
    SPI2_I2SPR.I2SDIV2 = 0;
    SPI2_I2SPR.I2SDIV3 = 0;
    SPI2_I2SPR.I2SDIV4 = 0;
    SPI2_I2SPR.I2SDIV5 = 0;
    SPI2_I2SPR.I2SDIV6 = 0;
    SPI2_I2SPR.I2SDIV7 = 0;

    // I2SODD = 1
    SPI2_I2SPR.ODD = 1;                             // para o STM32F407

    // CKPOL = 0
    SPI2_I2SCFGR.CKPOL = 0;
    
    // MCKOE = 1
    SPI2_I2SPR.MCKOE = 1;

    // SMOD = 1 (seleciona modo I2S)
    SPI2_I2SCFGR.I2SMOD = 1;

    // I2SSTD = 00 (I2S Phipils standard)
    SPI2_I2SCFGR.I2SSTD0 = 0;
    SPI2_I2SCFGR.I2SSTD1 = 0;

    // PCMSYNC = 0
    SPI2_I2SCFGR.PCMSYNC = 0;

    // CHLEN = 1 (32 bits no pacote total)
    SPI2_I2SCFGR.CHLEN = 1;
    
    // DATLEN = 01 (24 bits de dados)
    SPI2_I2SCFGR.DATLEN0 = 1;
    SPI2_I2SCFGR.DATLEN1 = 0;

    // CFG = 10 (MASTER TRANSMIT) OU 11 (MASTER RECEIVE)
    SPI2_I2SCFGR.I2SCFG0 = 1;
    SPI2_I2SCFGR.I2SCFG1 = 1;

    // interrupção de recebimento enable
    SPI2_CR2.RXNEIE = 1;
    NVIC_IntEnable(IVT_INT_SPI2);

    // I2SE = 1 (enable I2S2)
    SPI2_I2SCFGR.I2SE = 1;


    RCC_CR.HSEON = 1;                       // HSE ON
    RCC_PLLCFGR.PLLSRC = 1;                 // HSE como fonte para PLL e PLLI2S
    RCC_CR.PLLON = 1;                       // PLL ON
    RCC_CR.PLLI2SON = 1;                    // PLLI2S ON
    
    RCC_CFGR.I2SSRC = 0;                    // PLLI2S como fonte para I2S

    while(!RCC_CR.PLLRDY);                  // aguarda PLL
    while(!RCC_CR.PLLI2SRDY);               // aguarda PLLI2S

Regards...

Outcomes