cancel
Showing results for 
Search instead for 
Did you mean: 

I2S problem to change MCU from STM32F107 to STM32F407

gabrielvendramini
Associate II
Posted on April 06, 2015 at 20:41

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...
4 REPLIES 4
Posted on April 06, 2015 at 23:51

And so do you see any signals at the pins? What exactly is the failure more you're reporting?

Is there some code that configures the AF mode of the specific pins? ie GPIO_PinAFConfig() in the SPL

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
gabrielvendramini
Associate II
Posted on April 07, 2015 at 13:24

Hi,

The pins (Clock, data, left/right and clock aux) are floating.

I'm using the PCM1803A for audio ADC converter.

If I use this code with the MCU STM32F107, without the configuration for PLLI2SN and PLLI2SR (because it is specificaly for STM32F407)... it works well

The diference for this two models is that the STM32F4 MCU has a dedicated clock (PLLI2SCLK).

I configured this and put this clock on MCO2 output to check this (this MCU has this function). This is ok (about 86MHz for DIV = 3, ODD = 1, MCKE = 1, FS = 48kHz).

It is a little strange...

lowpowermcu
Associate II
Posted on April 07, 2015 at 15:29

Hi Gabriel,

If no signal on pads, I would suspect the GPIO cell.

FYI GPIO cell in STM32F4 family is different from STM32F1 family.

Cheers,

gabrielvendramini
Associate II
Posted on April 07, 2015 at 17:00

Hi, thanks.

I think the MikroE command are the same, like this (PB12 and PB13 as clock output):

GPIO_Clk_Enable(&GPIOB_BASE);

GPIO_Config(&GPIOB_BASE, (_GPIO_PINMASK_12 | _GPIO_PINMASK_13), (_GPIO_CFG_MODE_OUTPUT | _GPIO_CFG_MODE_ALT_FUNCTION | _GPIO_CFG_SPEED_MAX | _GPIO_CFG_OTYPE_PP));

The MCU is working with keypad, display... and everything is ok... But I'm checking this.

Regards.