STM32F042: UART application using CubeMX not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 06:41 AM
Anyone Helps me!
Anyone please show the basic USART's tx/rx code. Or check my CubeMX Project File.
HAL's USART won't work.
it code is generate from STM32Cube.
There is two USART, one(huart2) everytime send data to STM, another(huart1) everytime wait comming data.
But they won't work. For example, I wrote follow code.
​
```c
void sio_puts(char *str){
HAL_UART_Transmit(&huart1, (uint8_t *)str, strlen(str), 1000);
}
..
​
int main(void){
...
MX_USART2_UART_Init();
MX_USART1_UART_Init();
...
sio_puts("SerialTest\r\n");
...
while(1){...}
}
```
​
Params that baud, bit, and etc are correct setting.
Anyone would you show the basic code to use USART.
​
Maybe there is wrong with CubeMX settings.
I'll attach the .ioc file, so please check it​.
Thanks
- Labels:
-
STM32CubeMX
-
STM32F0 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 06:45 AM
It seems like nothing to do about USART's communication.
I thought it causes from interrupt priority so I set that 0-3, but it won't work.
If USART corrupted, where should I set the debug point?
Please help me!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 06:49 AM
If my post's code not sure, I do attach main.c. please check it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 07:21 AM
I understand `HAL_UART_Receive_IT` does regist myself as next callback. but `HAL_UART_RxCpltCallback` runs first call `HAL_UART_Receive_IT ` only.
it means nothing uart coming. and none response to send message, it wouldn't connect USART, huh?
But this circuit there is no wrong.
Then I think there is wrong settings in stmCubeMX, is it right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 07:42 AM
And when runs after ` HAL_UART_Receive_IT`, Timer callback won't run. but `while` in main process working.
it seems USART bring to freeze on STM's interrupt schedule. I hope this will be hint to solve this problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 08:48 AM
Hi @ssako​ ,
I advise you to refer to the "UART" examples provided in STM32CubeF0 package.
You find the examples under the path below:
STM32Cube_FW_F0_V1.9.0\Projects\STM32F042K6-Nucleo\Examples\UART
You may take the examples as a reference to develop your own application.
Khouloud.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 08:55 AM
Hi @ssako​ ,
I have also renamed your request: This will be more helpful for other users to understand your issue.
Hope you solve your issue soon.
Khouloud.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 09:30 AM
Thanks. then, you mean, mine CubeMX settings is not wrong?
​
I've ran examples, I noticed funny thing that I referenced source that It dedicated huart2, but run process always go "USART1_IRQHandler", not USART2_IRQHandler.
​
"UART_TWOBoards_ComIT", and receive Handle changes UartHandle Into huart2. below source places before "while()" in "main"
```
if(HAL_UART_Receive_IT(&huart2, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)
{
Error_Handler();
}
```
so maybe usart2's data won't come to STM. how should I to solve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 10:14 AM
It seems complex problem. Could you help me?
I think mine circuit is not wrong but, source code and CubeMX are correct, I have to doubt circuit.
But there is no weird point. and I modified circuit too simple. change the cable and so on.
Whatsover, I doubt CubeMX settings is weird. Could you inspect this one?​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-30 10:33 AM
I've tried as mbed, it uart transmission succeed. but mbed couldn't set GPIO as free.
so I have to make program in HAL.
Circuit is not wrong. May important problem in CubeMX setting. (it may not HAL, because source code is very simple.)
Anyone help me!