cancel
Showing results for 
Search instead for 
Did you mean: 

Potential bug with SPI3/I2S3 for STM32H753ZI

CLeo.1
Senior II

Hi guys!

I believe I found a bug with the SPI/I2S peripheral.

The initial problem started here: https://electronics.stackexchange.com/questions/571749/function-pointers-causing-unexpected-behaviour-within-stm32h753zi-microcontrolle?noredirect=1#comment1496642_571749

Were I thought it was a memory issue caused by the huge amount of function pointers that I added. But today with further debugging and taking away alot of the features. I just had the bare bones of the I2S3_Tx Buffer transmitting 1:1 ratios of the I2S1_Rx Buffer and I noticed it still existed, the problem.

I am probably going to be moving away from SPI/I2S and going with SAI to see if that avoids the issue but more so for the MUTE options and the mono features.

What happens is that on the FIRST run of the program is works perfectly, when I resend the SAME packet that enables the SPI1/I2S1 & SPI3/IS3 it makes the output on the SPI3/I2S3 a square like wave, where as the SPI1/I2S1 works flawlessly doesnt matter how many times its peripheral gets disabled or not.

The way the program works is that it waits (DMA) for a packet which in this case will be 0x03 which is ENABLE_INLINE. When the 0x03 packet is received on the first run it goes into it's respective handler function:

/*
 * UART_PACKET_PROCESSOR.c
 *
 *  Created on: May 13, 2021
 *      Author: Christopher
 */
 
#include <stdint.h>
#include <stdlib.h>
#include <constants.h>
#include <dspFactory.h>
#include <inputSourceFactory.h>
#include <opcode.h>
#include <packetProcessor.h>
#include <uartFactory.h>
 
static void (*messageReceived[255])(void);
 
 
void UART4_TRANSFERCOMPELTE_CALLBACK(uint8_t exitPacket) {
	//functions pointers
	uint8_t * packet;
 
 
	if (exitPacket) {
		packet = malloc(sizeof(uint8_t));
		packet[0] = exitPacket;
 
	} else {
		packet = getUART4_RxBUFF();
	}
 
	(*messageReceived[packet[0]])();
 
}
 
void load_functionHandlers() {
 
	messageReceived[0] = I2S_MuteHandler;
	messageReceived[1] = I2S_UnmuteHandler;
//	messageReceived[2] = SPDIF_MuteHandler;
//	messageReceived[3] = SPDIF_UnmuteHandler;
 
	messageReceived[3] = audioSelectorInlineHandler;
//	messageReceived[5] = audioSelectorBluetoothHandler;
//	messageReceived[6] = audioSelectorSPDIFHandler;
//	messageReceived[7] = audioSelectorHDMIHandler;
 
//	messageReceived[8] = audioSelectorInternalHandler;
//	messageReceived[9] = audioSelectorExternalHandler;
 
//	messageReceived[10] = setupIRHandler;
//	messageReceived[11] = disableTouchHandler;
//	messageReceived[12] = enableTouchHandler;
 
//	messageReceived[13] = nightRiderLightsHandler;
//	messageReceived[14] = rainbowLightsHandler;
 
	messageReceived[15] = volumeIncreaseHandler;
	messageReceived[16] = volumeDecreaseHandler;
//
	messageReceived[17] = n_12dB_subBass_notch_EQHandler;
	messageReceived[18] = n_9dB_subBass_notch_EQHandler;
	messageReceived[19] = n_6dB_subBass_notch_EQHandler;
	messageReceived[20] = n_3dB_subBass_notch_EQHandler;
	messageReceived[21] = _0dB_subBass_notch_EQHandler;
	messageReceived[22] = p_3dB_subBass_notch_EQHandler;
	messageReceived[23] = p_6dB_subBass_notch_EQHandler;
	messageReceived[24] = p_9dB_subBass_notch_EQHandler;
	messageReceived[25] = p_12dB_subBass_notch_EQHandler;
 
	messageReceived[26] =	n_12dB_Bass_notch_EQHandler;
    messageReceived[27] =	n_9dB_Bass_notch_EQHandler;
    messageReceived[28] =	n_6dB_Bass_notch_EQHandler;
	messageReceived[29] =	n_3dB_Bass_notch_EQHandler;
	messageReceived[30] =	_0dB_Bass_notch_EQHandler;
	messageReceived[31] =	p_3dB_Bass_notch_EQHandler;
	messageReceived[32] =	p_6dB_Bass_notch_EQHandler;
	messageReceived[33] =	p_9dB_Bass_notch_EQHandler;
	messageReceived[34] =	p_12dB_Bass_notch_EQHandler;
 
	messageReceived[35] =	n_12dB_lower_midrange_notch_EQHandler;
	messageReceived[36] =	n_9dB_lower_midrange_notch_EQHandler;
    messageReceived[37] =	n_6dB_lower_midrange_notch_EQHandler;
	messageReceived[38] =	n_3dB_lower_midrange_notch_EQHandler;
	messageReceived[39] =	_0dB_lower_midrange_notch_EQHandler;
	messageReceived[40] =	p_3dB_lower_midrange_notch_EQHandler;
	messageReceived[41] =	p_6dB_lower_midrange_notch_EQHandler;
	messageReceived[42] =	p_9dB_lower_midrange_notch_EQHandler;
	messageReceived[43] =	p_12dB_lower_midrange_notch_EQHandler;
 
	messageReceived[44] =	n_12dB_midrange_notch_EQHandler;
	messageReceived[45] =	n_9dB_midrange_notch_EQHandler;
    messageReceived[46] =	n_6dB_midrange_notch_EQHandler;
	messageReceived[47] =	n_3dB_midrange_notch_EQHandler;
	messageReceived[48] =	_0dB_midrange_notch_EQHandler;
	messageReceived[49] =	p_3dB_midrange_notch_EQHandler;
	messageReceived[50] =	p_6dB_midrange_notch_EQHandler;
	messageReceived[51] =	p_9dB_midrange_notch_EQHandler;
	messageReceived[52] =	p_12dB_midrange_notch_EQHandler;
 
	messageReceived[53] =	n_12dB_higher_midrange_notch_EQHandler;
	messageReceived[54] =	n_9dB_higher_midrange_notch_EQHandler;
    messageReceived[55] =	n_6dB_higher_midrange_notch_EQHandler;
	messageReceived[56] =	n_3dB_higher_midrange_notch_EQHandler;
	messageReceived[57] =	_0dB_higher_midrange_notch_EQHandler;
	messageReceived[58] =	p_3dB_higher_midrange_notch_EQHandler;
	messageReceived[59] =	p_6dB_higher_midrange_notch_EQHandler;
	messageReceived[60] =	p_9dB_higher_midrange_notch_EQHandler;
	messageReceived[61] =	p_12dB_higher_midrange_notch_EQHandler;
 
	messageReceived[62] =	n_12dB_presence_notch_EQHandler;
	messageReceived[63] =	n_9dB_presence_notch_EQHandler;
	messageReceived[64] =	n_6dB_presence_notch_EQHandler;
	messageReceived[65] =	n_3dB_presence_notch_EQHandler;
	messageReceived[66] =	_0dB_presence_notch_EQHandler;
	messageReceived[67] =	p_3dB_presence_notch_EQHandler;
	messageReceived[68] =	p_6dB_presence_notch_EQHandler;
	messageReceived[69] =	p_9dB_presence_notch_EQHandler;
	messageReceived[70] =	p_12dB_presence_notch_EQHandler;
 
	messageReceived[71] =	n_12dB_brilliance_notch_EQHandler;
	messageReceived[72] =	n_9dB_brilliance_notch_EQHandler;
	messageReceived[73] =	n_6dB_brilliance_notch_EQHandler;
	messageReceived[74] =	n_3dB_brilliance_notch_EQHandler;
	messageReceived[75] =	_0dB_brilliance_notch_EQHandler;
	messageReceived[76] =	p_3dB_brilliance_notch_EQHandler;
	messageReceived[77] =	p_6dB_brilliance_notch_EQHandler;
	messageReceived[78] =	p_9dB_brilliance_notch_EQHandler;
	messageReceived[79] =	p_12dB_brilliance_notch_EQHandler;
 
	messageReceived[80] =	n_12dB_Bass_lowShelf_EQHandler;
	messageReceived[81] =	n_9dB_Bass_lowShelf_EQHandler;
	messageReceived[82] =	n_6dB_Bass_lowShelf_EQHandler;
	messageReceived[83] =	n_3dB_Bass_lowShelf_EQHandler;
	messageReceived[84] =	_0dB_Bass_lowShelf_EQHandler;
	messageReceived[85] =	p_3dB_Bass_lowShelf_EQHandler;
	messageReceived[86] =	p_6dB_Bass_lowShelf_EQHandler;
	messageReceived[87] =	p_9dB_Bass_lowShelf_EQHandler;
	messageReceived[88] =	p_12dB_Bass_lowShelf_EQHandler;
 
	//messageReceived[89] =	disableLightsHandler;
}

From here we go into enabling the SPI1/IS21 and the SPI3/IS3 Peripherals

https://pastebin.com/8qiBPkHq

Then from there its just the DSP functions, however when I resend the packet thats where the issue starts the SPI1/I2S1 line is perfect but the SPI3/I2S3 line becomes a square wave.

Essentially where I believe the issue is when you try enabling SPI3/I2S3 then disabling it then enabling it again.

3 REPLIES 3

H7 with DMA, any chance this is a cache coherency issue?

If you send the same packets, should be easy enough to validate the buffer content each time, and take all potential down-stream code out of suspicion

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

Is there a question?

Observe the data on the I2S bus using LA.

Divide and conquer: to pinpoint where the problem stems from, exclude the data chain by generating fixed simple data e.g. sawtooth.

JW

I have no idea what cache choherency is! Yup double check the buffer content its the same when resending the same packet.