cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 read analog signal

lemac
Associate II
Posted on April 14, 2015 at 09:55

Hello

I have a nucleo STM32F103, I put a  external clock of 25MHz.

How can i read a analog signal conected in PB8?

Someone can help me??

Best regards

#analog-input #nucleo-f103rb
7 REPLIES 7
l239955_stm1
Associate II
Posted on April 14, 2015 at 14:21

- set ADC configuration, enable adc channels, GPIO set as ''analog mode''

- set DMA channel  configuration

- transfer analog value to memory through DMA

raptorhal2
Lead
Posted on April 14, 2015 at 15:20

ADC analog channels have fixed pin assignments, unlike other peripherals which may have a choice of pins. PB8 is not an ADC channel.

Read the data sheet Section 3 Pin Assignments table and choose an appropriate pin e.g., PA1.

Whichever peripheral library you are using will have ADC examples you can adapt for your project.

Cheers, Hal

lemac
Associate II
Posted on April 16, 2015 at 18:40

Hello

I changed this signal from PB8 to PB1 and my code continue without work.

I am using the sample code stsw-stm32028

but i don't understand veyr well it.

Someone can send me code example?

Best Regards

Posted on April 16, 2015 at 19:50

Download the STM32F1 firmware library, there are ADC examples in that.

http://www.st.com/web/en/catalog/tools/PF257890

Ignore the Cube messaging, go to the red download button at the bottom.

Not sure it's going to be useful for a 25 MHz signal, but that's either poorly expressed, or unrelated.

You have an F103 or F105 part?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
raptorhal2
Lead
Posted on April 16, 2015 at 19:54

The STM32028 examples should work on your nucleo with simple adaptation.

PB1 is ADC123 channel 9. None of the 7 examples in STM32028 use Channel 9.

Which of the 7 examples are you using? Did you change the example channel to channel 9?

Unless we see the code, we can only guess what is wrong.

Regards, Hal

lemac
Associate II
Posted on April 17, 2015 at 08:23

Hello

All right Clive1: I have a Nucleo-F103RB but i changed the microcontroller and i put a STM32F I put a external clock at 25MHz. It is very similar to my final product Baird.hal.001: I am using the example with this path ''stsw-stm32028\STM32F10x_AN3116_FW_V1.0.0\Project\ADC Modes\SingleChannelContinuous'' I changed GPIO_Configuration

GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOB, &GPIO_InitStructure);

And now I chaged ADC_Channel_14 for ADC_Channel_9 Now all work. I only have a final question. can i use Port PB8 for analog adquisition??? Best regards
Posted on April 17, 2015 at 12:33

I only have a final question. Can i use Port PB8 for analog acquisition???

The

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00220364.pdf

says it's not connected to an ADC, so no. Didn't Hal already mention that?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..