Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32G4: UART5 IRQ not working #15265

Closed
pilotak opened this issue Apr 13, 2022 · 9 comments · Fixed by #15269
Closed

STM32G4: UART5 IRQ not working #15265

pilotak opened this issue Apr 13, 2022 · 9 comments · Fixed by #15269

Comments

@pilotak
Copy link
Contributor

pilotak commented Apr 13, 2022

Description of defect

When using UnbufferedSerial on UART5, irq is never called, so i looked at the https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32G4/serial_device.c and i discovered that there is no UART5 support so i simply added following, but still no success. Reading the serial "classic" way in main() works.

On USART1 irq works as expected.

During search i also found that UART4_BASE is incorrectly set as USART4_BASE and USART3_4_LPUART1_IRQn doesn't exists it should be UART4_IRQn. Also under LPUART irq is set to USART3_4_LPUART1_IRQn but should be LPUART1_IRQn but that is not part of this issue.

to the top

#if defined(UART5_BASE)
static void uart5_irq(void)
{
    uart_irq(UART_5);
}
#endif

in serial_irq_set()

#if defined(UART5_BASE)
    if (obj_s->uart == UART_5) {
        irq_n = UART5_IRQn;
        vector = (uint32_t)&uart5_irq;
    }
#endif

and to serial_get_irq_n()

#if defined(UART5_BASE)
        case UART_5:
            irq_n = UART5_IRQn;
            break;
#endif

Is there anything else that needs to be done in order to get irq on UART5 working?

Target(s) affected by this defect ?

STM32G4 specifically G484VE

Toolchain(s) (name and version) displaying this defect ?

GCC ARM 9.3.1

What version of Mbed-os are you using (tag or sha) ?

99cb885

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

mbed-cli 1.10.1

How is this defect reproduced ?

#include "mbed.h"

UnbufferedSerial serial(PC_12, PD_2); // UART5
//UnbufferedSerial serial(PA_9, PA_10); // USART1

volatile bool test = false;

void cb() { // ISR
    char rec = 0;
    serial.read(&rec, 1); // clear

    test = true;
}

int main() {
    serial.baud(115200);
    serial.format(8, SerialBase::None, 1);
    serial.attach(callback(cb));

    while (1) {
        /*while (serial.readable()) {
            char rec = 0;

            serial.read(&rec, 1);
            printf("data: %02X\n", rec);

        }*/
        if (test) {
            test = false;
            printf("test\n");
        }
    }
}
@0xc0170
Copy link
Contributor

0xc0170 commented Apr 19, 2022

cc @ARMmbed/team-st-mcd

@jeromecoutant
Copy link
Collaborator

Hi @pilotak

Please check #15269, few issues analysed:

  • UART4_BASE instead of USART4_BASE
  • correct IRQ name
  • UART5 was missing
  • UART ASYNC was not enabled (no check at UnbufferedSerial level...?)

@pilotak
Copy link
Contributor Author

pilotak commented Apr 20, 2022

Many thanks @jeromecoutant for stepping into this, the PR changes are exacly the same i did last week locally, but unfortunately UART5 IRQ is not working

@jeromecoutant
Copy link
Collaborator

the PR changes are exacly the same i did last week locally, but unfortunately UART5 IRQ is not working

All changes....? :-(

@pilotak
Copy link
Contributor Author

pilotak commented Apr 20, 2022

Except the part with UART_NUM per chip and SERIAL_ASYNCH definition. I have checked out the PR to be up to date and it's not functional.
I also checked it on the o-scope and the information is on correct pin

@jeromecoutant
Copy link
Collaborator

Could you check with?
__HAL_RCC_UART5_CONFIG(RCC_UART5CLKSOURCE_HSI);

@pilotak
Copy link
Contributor Author

pilotak commented Apr 26, 2022

I changed it at

__HAL_RCC_UART5_CONFIG(PeriphClkInit->Uart5ClockSelection);
and it works, strangely when putting it back it it works too, maybe it gets remebered...

@jeromecoutant
Copy link
Collaborator

I don't think that current code is calling the part you mentioned.
And maybe "HSI clock on" is mising in my proposition....
But I changed #15269 yesterday, could you check and maybe approve ? :-)

@pilotak
Copy link
Contributor Author

pilotak commented Apr 26, 2022

Silly me, i have checked out the yesterday PR and also did HSI change in one go, that is the reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants