2019-03-19 05:43 AM
My environment is Nucleo-F446RE with STM32CubeMX 5.1 / TrueSTUDIO 9.3.
I created an I2S master transmit test program. [Full project archive is
here]
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
#define I2S_CODE 0b1010110011110000
#define I2S_BUFFER_SIZE 64
#define I2S_BUFFER_HALF_SIZE (I2S_BUFFER_SIZE / 2)
uint16_t buffer[I2S_BUFFER_SIZE];
void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
{
uint16_t *sp = buffer;
for(int i = 0; i < I2S_BUFFER_HALF_SIZE; i++) *(sp++) = I2S_CODE;
}
void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
{
uint16_t *sp = buffer + I2S_BUFFER_HALF_SIZE;
for(int i = 0; i < I2S_BUFFER_HALF_SIZE; i++) *(sp++) = 0x00;
}
void StartI2STransfer()
{
memset (buffer, 0, sizeof(buffer));
HAL_I2S_Transmit_DMA(&hi2s2, buffer, I2S_BUFFER_SIZE * sizeof(uint16_t));
}
/* USER CODE END 0 */
int main(void)
{
/* Infinite loop */
/* USER CODE BEGIN WHILE */
StartI2STransfer();
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
However, STM32F4 outputs a same signal twice.
For example, in this program, I put the I2S signal as "10101100111100001010110011110000...". But a output signal is "10101100101011001111000011110000..." like this image.
Please tell me how to solve this problem.
Solved! Go to Solution.
2019-03-19 11:00 AM
2019-03-19 11:00 AM
2019-03-20 04:17 AM
After changing a parameter to "Half Word", that signal was output as I expected. Thank you so much.