STM32F401 UART

For general Flowcode discussion that does not belong in the other sections.
Alan_37
Posts: 126
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 7:23 pm
Has thanked: 37 times
Been thanked: 17 times

Re: STM32F401 UART

Post by Alan_37 »

Hi ,

The project is 4 months of work and it got pretty big and complicated

My main problem with it is that the uarts stop responding if operated at the same time
so i had to implement a lot of workarounds like disable Uart1 interrupt when Uart 2 is receiving
or transmitting and Vis versa . but now I feel there must be a better way so was hoping
to do in a different way .

Also hope this problem is not coming from bad clock RCC setting as the other problems :)

Leigh , thank you very much for your time, help & suggestions, I will try to do it my self
if I succeed will post the code here maybe some one will have the same issue and
can benefit from it .

Regards

Alan

chipfryer27
Valued Contributor
Posts: 1149
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: STM32F401 UART

Post by chipfryer27 »

Hi

You mentioned earlier that you lost your data when using the circular buffer component. Depending on component macro used you have the option to remove data or leave it alone.

Having the UARTS receive on an interrupt is how I use them. My ISR usually just puts the byte into a CB for processing later. I usually have a "start" and "stop" character included in what I send and these are fixed. In my main loop I'll poll the CB to see if these characters are present and if so I know I have data to process.

I haven't had issues using two UARTS running at 9600. No missed data as the uC branched as Leigh described.

Regards

Alan_37
Posts: 126
Joined: Thu Dec 03, 2020 7:23 pm
Has thanked: 37 times
Been thanked: 17 times

Re: STM32F401 UART

Post by Alan_37 »

Hi ,

I lost data not because of the CB , but cos of the workarounds i had to implement to reduce
the Uart stop functioning , i had to disable uart INT when the other is operating .
with the following c codes .

__HAL_UART_DISABLE_IT(&MX_UART_NUMBER_1, UART_IT_RXNE);
__HAL_UART_ENABLE_IT(&MX_UART_NUMBER_2, UART_IT_RXNE);


when the uart stops responding will still be able to transmit but the interrupt will not get triggered anymore
It is strange i don't know why this is happening .

The 2 Uarts are operating at different Rates 1200 , and 115200

I am learning that these STM devices are powerful but somehow very fragile and much more complicated
to work with .

I worked with dual Uart in the past on AVR and Pic never had all this problems .

Alan_37
Posts: 126
Joined: Thu Dec 03, 2020 7:23 pm
Has thanked: 37 times
Been thanked: 17 times

Flowcode v10 Re: STM32F401 UART

Post by Alan_37 »

Hi again ,

So I was able to replicate the problem with the program sent to me by LeighM
I have modified a bit the program and also recorded a small video
you can watch on the following URL

https://www.canva.com/design/DAF6jlIzm3 ... esignpanel

Also Attaching the modified flowcode programm
Attachments
STM32F401_DUAL_UART.fcfx
(22.79 KiB) Downloaded 124 times

LeighM
Valued Contributor
Posts: 401
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 71 times
Been thanked: 217 times

Re: STM32F401 UART

Post by LeighM »

This is a bit of a long shot, but could you try this edit and see if it helps?

Look in C:\ProgramData\MatrixTSL\FlowcodeV10\FCD\ARM
and edit 32F401RC.fcdx
At line 537 change the '1' to '2'
enable='HAL_NVIC_SetPriority(USART2_IRQn, 0, 2);

Re-load the project (or restart Flowcode)

Alan_37
Posts: 126
Joined: Thu Dec 03, 2020 7:23 pm
Has thanked: 37 times
Been thanked: 17 times

Re: STM32F401 UART

Post by Alan_37 »

Hi ,

Just Tested now same problem still

I have edit the file when flowcode was closed .

shall I put the value back to 1 ?

LeighM
Valued Contributor
Posts: 401
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 71 times
Been thanked: 217 times

Re: STM32F401 UART

Post by LeighM »

OK. Thanks. Yes, back to 1

Alan_37
Posts: 126
Joined: Thu Dec 03, 2020 7:23 pm
Has thanked: 37 times
Been thanked: 17 times

Re: STM32F401 UART

Post by Alan_37 »

Hi LeighM ,

I might have found something to help you solve the Mistry or at least point you in the right direction .

when the UART fail and the Interrupt is not being triggered any more the following C code will bring it back to life
it will fail again and again but this line always fixes it for a few seconds .

Code: Select all

HAL_UART_Receive_IT(&(MX_HANDLE_UART1), (uint8_t *)&(MX_HANDLE_UART1_RX_VAL), 1);
It might be a data Overrun error , I was not able to read the Flag with Hal

I know this is not a good solution but it seems to work LOL I put the following lines in an interrupt timer of 5Hz and it will never fail lol :)

Code: Select all

// IF uart Status is "ready"  fix it :) lol 


if (HAL_UART_GetState(&MX_UART_NUMBER_1) == HAL_UART_STATE_READY) 
      { HAL_UART_Receive_IT(&(MX_HANDLE_UART1), (uint8_t *)&(MX_HANDLE_UART1_RX_VAL), 1);}

Alan_37
Posts: 126
Joined: Thu Dec 03, 2020 7:23 pm
Has thanked: 37 times
Been thanked: 17 times

Re: STM32F401 UART

Post by Alan_37 »

If you need to test something on my setup just let me know .

Regards

Alan

Alan_37
Posts: 126
Joined: Thu Dec 03, 2020 7:23 pm
Has thanked: 37 times
Been thanked: 17 times

Re: STM32F401 UART

Post by Alan_37 »

Hi again ,

So here is an update using the c code in a timer interrupt works for a wile but after some time the MCU
stop working entirely not only the UARTS!

So i was thinking to use the uarts in software mode , but as I mentioned the RX interupt dose not work in software mode
like it dose on the STM32f407GZ , so please any one can help to enable 2 custom interrupts on the falling edge of B7 and A3 for the STM32f401

Also is martix still doing the bug fixes in v10 ARM cos I remember there was a time where these problems where fixed
in a matter of hours .

Regards

Alan

Post Reply