STM32L152C-DISCO UART doesn't work correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-15 4:44 AM
I want to send the numbers in order but it only sends the number 0 constantly. When I make the delay 100ms it only sends 0 and 1. When I remove the delay completely, it sends numbers from 1 to 30 in order.
Solved! Go to Solution.
- Labels:
-
STM32L1 Series
-
UART-USART
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-15 6:31 AM
Sounds like it's resetting due to a watchdog or other event sometime 200-300ms after reset. That would explain all behavior.
Disable watchdog in option bytes.
Monitor NRST line to verify reset.
Read and clear RCC->CSR bits on startup to determine cause of reset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-15 5:15 AM
I woudl try this code with external crystal oscilator. Or measure the USART output with osciloscope or LA (if timing is correct).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-15 5:54 AM
I tried with external 16MhZ crystal oscilator.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-15 6:13 AM
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
In this code is used internal oscilator. I dont know what you try.
Are some pulses on the Tx output or line hungs to L/H after some time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-15 6:24 AM
I tried with external 16MhZ crystal oscilator but now i'm using internal OSC.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-15 6:31 AM
Sounds like it's resetting due to a watchdog or other event sometime 200-300ms after reset. That would explain all behavior.
Disable watchdog in option bytes.
Monitor NRST line to verify reset.
Read and clear RCC->CSR bits on startup to determine cause of reset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-03-15 6:49 AM
I disabled watchdog in option bytes. It is working now
