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
STM32F401 UART
-
- Posts: 141
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 03, 2020 7:23 pm
- Has thanked: 43 times
- Been thanked: 19 times
-
- Valued Contributor
- Posts: 1207
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 294 times
- Been thanked: 424 times
Re: STM32F401 UART
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
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
Re: STM32F401 UART
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 .
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 .
Re: STM32F401 UART
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
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 239 times
-
- Valued Contributor
- Posts: 401
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 74 times
- Been thanked: 218 times
Re: STM32F401 UART
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)
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)
Re: STM32F401 UART
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 .
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
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);
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);}
Re: STM32F401 UART
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
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