cancel
Showing results for 
Search instead for 
Did you mean: 

Block for sending values through the UART

anso-engineer
Associate

Hello, I am trying to wire STM32F103C8T6 with DS18B20 sensor and I realize that after some actions it stopped to work and no data through the UART sent:

stm32-proteus.png

cube-ide-clock-configuration.png

stm-32-rcc.png

usart-1.png

usart-2.png

  Probably it's not big deal, but I have no idea why UART completelly blocked and sending no information.
Current version of this code based on the materials of:
 https://deepbluembedded.com/stm32-1-wire-one-wire-protocol-ds18b20-code-example/ 

  

6 REPLIES 6

You'll have to debug it. Your output buffer isn't really big enough to hold the string and NUL termination.

Try something more like

int number = 123;
uint8_t numarray[8]; // make sure you have enough space
...
while(1)
{ // sprintf returns the string length
  HAL_UART_Transmit(&huart1, numarray, sprintf(numarray, "%d\n", number), 1000);
}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I extended buffer size but unfortunately nothing changed...
Can be something wrong with configuration I applied?

No idea

Do you have actual hardware? Can you put a scope on the signals, and use a debugger?

Check the code that configures the pins.

Do you have a supervisor or trainer?

Do you have any other working example in this environment?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Here is the example of simplified versions from Proteus. So generally, it can recognise the environment and working with UART.

proteus-workable-example.png

I don't have this temp sensor right now. Code comparsion between this simple UART example and code I plan to adapt. Left version is the code which works:

stm-32-code-diff-1.png

stm-32-code-diff-2.png

stm-32-code-diff-3.png

stm-32-code-diff-4.png

stm-32-code-diff-5.png

stm-32-code-diff-6.png

anso-engineer
Associate

I don't have an local trainer or any support. So I took a chance here.

Proteus has a debugger which allows you to step through the code - doesn't it?

So have you done that?

 

It also has "virtual" instruments (akin to oscilloscopes, etc) to observe signals external to the MCU.

Have you used them?

 

Have you got the UART working without the DS18B20 sensor?

 

Some tips here on getting started with STM32 - including debugging:

https://community.st.com/t5/stm32-mcus-products/for-better-learning-stm32-programming-and-debugging/m-p/719468/highlight/true#M260690