How to read/write 16bit from I2S

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
NiVa_4337911
Level 3
Level 3
First like received

Unfortunately, there is no DMA in the chip I am using, so only way to read a byte from I2S is using the function "uint8 I2S_ReadByte(wordSelect)", here the word select is the channel ( L or R). Since my data has 16 bits, how can I get the next byte? I am not sure whether a second read will return next byte or not. I couldn't find anything in the documentation.

0 Likes
1 Solution
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello NiVa_4337911 ,

The RX FIFO has a depth of 4, thus you can use it for receiving upto 32 bits. Thus, the I2S_ReadByte() needs to be called twice in order to read both the bytes. You need to take care in the firmware that the RX_FIFO is not empty before reading the data and also that the RX_FIFO overflow does not occur. You can use the I2S_ReadRxStatus() function for this purpose.

Regards

Ekta

View solution in original post

0 Likes
1 Reply
Ekta_N
Moderator
Moderator
Moderator
750 replies posted First like given 250 solutions authored

Hello NiVa_4337911 ,

The RX FIFO has a depth of 4, thus you can use it for receiving upto 32 bits. Thus, the I2S_ReadByte() needs to be called twice in order to read both the bytes. You need to take care in the firmware that the RX_FIFO is not empty before reading the data and also that the RX_FIFO overflow does not occur. You can use the I2S_ReadRxStatus() function for this purpose.

Regards

Ekta

0 Likes