Temperature sensor

General discussion on mikroBasic PRO for ARM.
Post Reply
Author
Message
ART_ME
Posts: 22
Joined: 19 Dec 2016 09:48

Temperature sensor

#1 Post by ART_ME » 05 Feb 2017 16:52

Hello.
I need help to read data from temperature sensor of STM32F103C8. The datasheet show: The temperature sensor is internally connected to the ADC12_IN16 input channel.
However, when I write:

Code: Select all

ADC_Set_Input_Channel(_ADC_CHANNEL_16) 
ADC1_Init()                                           
adc_result = ADC1_Get_Sample(16)
I see the error: 303 Identifier "_ADC_CHANNEL_12" was not declared"
But _ADC_CHANNEL_0......_ADC_CHANNEL_9 no such error.
How I can read temperature sensor (this data will send via the UART to PC)?
Last edited by ART_ME on 07 Feb 2017 08:05, edited 1 time in total.

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: Temperature sensor

#2 Post by lana.arsic » 06 Feb 2017 18:30

Hi,

You can take a look in datasheet (on page 10):

http://www.st.com/content/ccc/resource/ ... 161566.pdf

STM32F103C8 has ADC with 10 channels.

You can take a look in LM35 example in the compiler, it is located in installation folder, for example in:

c:\Users\Public\Documents\Mikroelektronika\mikroC PRO for ARM\Examples\ST\Development Systems\EasyMx PRO v7 for STM32 ARM\LM35\

Best regards,
Lana

ART_ME
Posts: 22
Joined: 19 Dec 2016 09:48

Re: Temperature sensor

#3 Post by ART_ME » 07 Feb 2017 05:06

Dear Lana,

You're right

ADC_Set_Input_Channel
This routine is available only for MCUs with ADC module located on GPIO pins.


May be istead:

Code: Select all

ADC_Set_Input_Channel(_ADC_CHANNEL_16)
ADC1_Init()                                           
adc_result = ADC1_Get_Sample(16)
will work:

Code: Select all

ADC1_Read(16)
:!:

Post Reply

Return to “mikroBasic PRO for ARM General”