cancel
Showing results for 
Search instead for 
Did you mean: 

i2s_write write data in the buffer

stack:

Zephyr on stm32n6 (nucleo_n657x0_q)

When sending a buffer over sai via i2s_write data is written into the buffer.

I expected the TX buffer to be treated as read-only and remain unchanged by the driver.

It's only ever the first 2 numbers.

Why is that?

 

 

Example code:
int16_t tx_block_test[96] = {0};
woutervanbastelaere_0-1764066242270.png

 

In attachment a minimal version of a project that displays this issue.

1 ACCEPTED SOLUTION

Accepted Solutions

(declaring the buffer as const did raise warnings.)

 

I found what the issue is.

I2s_write expect's it's buffer to be from the memory slab that was assigned in I2s's config.

And at the end of i2s_write the memory block is freed to the memory slab.

 

Memory slabs store data about the linked list of all their buffers in the first 4 bytes of empty buffers.

Meaning that when i2s_write finishes the memory slab mistakenly attempts to put it back in it's linked list of buffers. Which writes data into the first 4 bytes.

 

View solution in original post

2 REPLIES 2
Saket_Om
ST Employee

Hello @wouter-van-bastelaere 

Try using a buffer declared as const with i2s_write to check if the compiler issues any warnings or errors.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om

(declaring the buffer as const did raise warnings.)

 

I found what the issue is.

I2s_write expect's it's buffer to be from the memory slab that was assigned in I2s's config.

And at the end of i2s_write the memory block is freed to the memory slab.

 

Memory slabs store data about the linked list of all their buffers in the first 4 bytes of empty buffers.

Meaning that when i2s_write finishes the memory slab mistakenly attempts to put it back in it's linked list of buffers. Which writes data into the first 4 bytes.