That last statement shows you perhaps don't have a full understanding of what you are doing here.
However, the most likely cause of your troubles is that the examples you have are using an SDK from ST, and you either don't have the SDK installed and set up correctly, or you aren't using it in your project, or you have simply forgotten to include the appropriate headers at the start of your C file.
I have not used ST's tools myself, but I would expect that their SDK comes with complete working example projects for some evaluation boards. Start with one of these, and adapt it to suit your required changes.
You don't use the GPIO port Alt Function Register for making a pin an analogue input. You do it by setting the mode bits for that pin in the GPIO Mode register. There are two bits for each pin, coded like this:
Bits 2y:2y+1 MODERy[1:0]: Port x configuration bits (y = 0..15) These bits are written by software to configure the I/O direction mode.
00: Input (reset state)
01: General purpose output mode
10: Alternate function mode
11: Analog mode
I don't have any shareable examples that don't use DMA with scan and usually continuous mode for the ADC which I think might be distracting.
Each analog channel is hard tied internally to a given pin. (They are all port A from my memory, but scattered about a bit). Read the device reference manual for a listing of the capability of each pin.
Funct Reg for the port pin. I was hoping to find a complete example of such .
For 100MHz clock, even 480 cycles are more than enough.
coded, does it mean only port A can be analog?
OK, i will have dig a bit deeper in the reference manual.
This info is critical for someone like me new to the STM chip.
For the (microchip/Atmel) ?A SAM world, we have to set them explicitly .
PORT->Group.DIRCLR.reg = PORT_PB09; // Enable the peripheral multiplexer for PB09 PORT->Group.PINCFG.reg |= PORT_PINCFG_PMUXEN; // Set PB09 to function B which is analog input. PORT->Group.PMUX.reg = PORT_PMUX_PMUXO_B;