cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F427 SPI4 I2S - Spi Registers not accepting Writes

Joe.H
Senior

First time using a STM32F4 for I2S.

I don't use your libraries as I want to understand the cpu at the register level.

I set up the I2S PLL and enable the I2S clock.

When I start to write to the SPI4 registers, they are not accepting the data. I have found this behavior before when the clocks were not enabled but I believe I have properly done that.

I have a simple test I am using to validate my understanding - please see the code below.

Please comment as to why writes to the SPI4 registers are not being taken.

void Do_Audio(void)
{
	int Num_Audio_Samples = sizeof(AA) / 2;
	int I = 0;
 
    RCC->APB2ENR |= RCC_APB2ENR_SPI4EN;	// turn SPI4 clock on
 
	Config_STM_Pin(GPIOE, 2, 5, H_GPIO_Alt_Function, H_GPIO_Output_PushPull, SlewRate_Medium, No_Pull_Up_or_Down);	// I2S_Bclk
	Config_STM_Pin(GPIOE, 4, 5, H_GPIO_Alt_Function, H_GPIO_Output_PushPull, SlewRate_Medium, No_Pull_Up_or_Down);	// I2S_LRClk
	Config_STM_Pin(GPIOE, 6, 5, H_GPIO_Alt_Function, H_GPIO_Output_PushPull, SlewRate_Medium, No_Pull_Up_or_Down);	// I2S_Data
 
	AudioMutePIN(1);	// mute off
 
// set up I2SPLL
 
	RCC->PLLI2SCFGR = (271 << RCC_PLLI2SCFGR_PLLI2SN_Pos) | (2 << RCC_PLLI2SCFGR_PLLI2SR_Pos);	// this gives correct I2S_clock
 
	// enable I2S clock
 
	RCC->CR |= RCC_CR_PLLI2SON;
 
	// wait until stable
 
	while((RCC->CR & RCC_CR_PLLI2SRDY) == 0)
	{}
 
 
	// set up SPI4
 
	SPI4->I2SCFGR = SPI_I2SCFGR_I2SMOD | (2 << SPI_I2SCFGR_I2SCFG_Pos);
 
	SPI4->I2SPR = 6;	// odd = 0,  idiv = 6
 
	SPI4->I2SCFGR |= SPI_I2SCFGR_I2SE;
 
	while(1)
	{
		if(SPI4->SR & SPI_SR_TXE)
		{
			SPI4->DR = AA[I];
 
			I++;
 
			if(I >= Num_Audio_Samples)
				I = 0;
		}
	}
}

These 3 lines of code are not being updating the specified registers

SPI4->I2SCFGR = SPI_I2SCFGR_I2SMOD | (2 << SPI_I2SCFGR_I2SCFG_Pos);

SPI4->I2SPR = 6; // odd = 0, idiv = 6

SPI4->I2SCFGR |= SPI_I2SCFGR_I2SE;

Thanks in advance for any comments.

Joe

1 ACCEPTED SOLUTION

Accepted Solutions

SPI4 in STM32F427 does not have I2S. Only SPI2 and SPI3 do.

JW

View solution in original post

2 REPLIES 2

SPI4 in STM32F427 does not have I2S. Only SPI2 and SPI3 do.

JW

Joe.H
Senior

Thanks.

Now that you say that - I see the fine print difference.

I wish ST would make that a little clearer.

Thanks again