STM32 devices are great but the only problem with them is when it comes to programming. Register based programming is not easy, because clock setting is very messed up, and there aren’t any reliable libraries. ST microelectronics provides HAL libraries but that is also not so good. Nevertheless I am going to use HAL libraries as they are officially supported by ST and also it have a good community support.
First start (S) is transmitted by microcontroller. Next uc sends address of the device, on receiving address, device sends the A (ack) signal back to uc.
Next uc sends data bits (04, 00, 24, 20). After receiving each data byte, device sends the A(ack) to uc.
At last uc sends P( stop) signal to indicate the end of communication.
ADC is used by most of the sensors for eg- temperature sensor, force sensor, IR sensor, potentiometer, and many more. All these sensors send the data to the microcontroller in analogue form, which then converts it into digital values.
The process is very straight forward, you have to measure the number of times input pin goes high and low in 1 second. This measure will give you the frequency.
1.) Set a pin as input and make sure you connect a pull-up register to it. Pull-up is necessary otherwise pin will not go to high state.
2.) Give in the frequency input to the pin and display the frequency on the serial terminal via UART.