brilliantgaq.blogg.se

Cosmic c compiler
Cosmic c compiler








  1. #Cosmic c compiler how to#
  2. #Cosmic c compiler serial#

But for making the processes easier, I made another header file that can be found on GitHub with the link below. To program for ADC functionalities on STM8S, we will be using the Cosmic C compiler along with the SPL libraries.

cosmic c compiler

You can see the two potentiometers on the right and the ST-link programmer on the left. Once the connections are done, my hardware looks like this as shown below. Then we will also calculate the equivalent voltage value and display it on the LCD, do remember that our controller is powered by 3.3V, so even if we provide 5V to the ADC pin, it will be able to read only from 0V to 3.3V. We will be programming our controller to read this analog voltage in digital value (0 to 1024) and display it on the LCD screen. The potentiometers are connected in such a way that when we vary it, we will get 0-5 V on our analog pins.

cosmic c compiler

These pots are connected to the ports PC4 and PD6, which are the ANI2 and ANI6 pins as discussed on the pinout image earlier. The complete circuit diagram used in this project is given below, it is very similar to the STM8S LCD tutorial that we discussed previously.Īs you can see, the only additional components apart from the LCD are two potentiometers POT_1 and POT_2. Circuit Diagram to Read ADC Values on STM8S and Display on LCD We can easily change this 0-5V by changing the operating voltage of the MCU if required. This means that our 10-bit ADC will read 0 when 0V(Vss) is provided and will read a maximum of 1024 when 3.3V(Vdd) is provided. With 3.3V as the operating voltage, our ADC clock frequency can be set between 1 to 4MHz and our conversion voltage range is between 0V to 3.3V. In the above table, Vdd represents operating voltage and Vss represents the ground. So in our case on our development board, we have the microcontroller operating on 3.3V, you can check the development board circuit diagram from the getting started with the STM8S tutorial. Other important ADC characteristics for STM8S103P36 can be found in the below table taken from the datasheet.

#Cosmic c compiler serial#

Do note that it will not be possible to use the same pin for all three purposes, so if we are using these two pins for ADC, then we will not be able to perform serial communication. On the STM8S103F3P6, we have an ADC with 5 Channel and 10-bit resolution  with a 10-bit resolution, we will be able to measure the digital value from 0 to 1024 and a 5 channel ADC indicates that we have 5 pins on the Microcontroller which can support ADC, these 5 pins are highlighted in the picture below.Īs you can see, all these five pins (AIN2, AIN3, AIN4, AIN5, and AIN6) are multiplexed with other peripherals, meaning apart from just acting as an ADC pin, these pins can also be used for performing other communications like for example, the pin 2 and 3 (AIN5 and AIN 6) can not only be used for ADC but can also be used for serial communication and GPIO functions.

cosmic c compiler

There are many types of ADC and each microcontroller has its own specifications. To do this, we will need the following components.

cosmic c compiler

In this article, we will be reading two analog voltage values from two potentiometers and display its ADC value on a 16x2 LCD display.

#Cosmic c compiler how to#

So in this article, let's learn how to use ADC on STM8S Microcontroller with COMIC C compiler. But our microcontrollers and microprocessors are digital devices and they will not be able to measure these parameters without an important peripheral called Analog to Digital Converters (ADC). An ADC is a very useful peripheral on a microcontroller that is often used by embedded programmers to measure units that are in constant change like the varying voltage, current, temperature, humidity, etc.Īs we know “We live in an analog world with digital devices”, meaning everything around us like wind speed, light intensity, temperature, and everything we deal with like speed, velocity, pressure, etc. Now, proceeding with it on this tutorial, we will learn how to use the ADC feature on our STM8S103F3P6 Microcontroller. If you are a regular reader who is following our STM8S Microcontroller Tutorials, you would know that in our last tutorial, we learned how to interface a 16x2 LCD with STM8s.










Cosmic c compiler