AnsweredAssumed Answered

STM32F746G Discovery UART MIDI

Question asked by J.Tobbe on Oct 24, 2016
Latest reply on Oct 24, 2016 by J.Tobbe

I'd like to use the UART for MIDI input.

I've configured the UART on my STM32F7-Discovery board and perform a led toggle whenever an incoming message is received. I'm using the interrupt mode similar to the Cube firmware example "UART_TwoBoards_ComIT". However my receive buffer is unchanged and I've initialized it with dummy-data just to confirm that it doesn't seem to get updated by the USART6_IrqHandler routine.

What I get is a "frame error" in the UART_ErrorCallback routine. Could this have anything to do with the fact that a MIDI-note down consists of 3 bytes? When I hit a note on the MIDI-keyboard the IRQ-handler is only triggered once! This is unlike how I've worked with UART on other platforms. Then the incoming callback is triggered three times on a MIDI note-on event since it consists of 3 bytes.

void USART6_IRQHandler(void)
    extern uint8_t aRxBuffer[];
    BSP_LCD_DisplayIntAt(0, 70, *(UartHandle.pRxBuffPtr), CENTER_MODE);

void my_UART_Init(UART_HandleTypeDef *UartHandle)
    UartHandle->Instance        = USART6;
    UartHandle->Init.BaudRate   = 31250;
    UartHandle->Init.WordLength = UART_WORDLENGTH_8B;
    UartHandle->Init.StopBits   = UART_STOPBITS_1;
    UartHandle->Init.Parity     = UART_PARITY_NONE;
    UartHandle->Init.HwFlowCtl  = UART_HWCONTROL_NONE;
    UartHandle->Init.Mode       = UART_MODE_TX_RX;
    UartHandle->AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
    if(HAL_UART_DeInit(UartHandle) != HAL_OK)
    if(HAL_UART_Init(UartHandle) != HAL_OK)