5 years, 2 months ago.

Can we remap pins on the Nucleo F103RB (e.g. PA_3 to Analog In) with mbed compiler?

Hi, As a newbie, I'd like to use the extra pins available for Analog In on the Nucleo F103RBT6 but need to remap from their default setting. I've searched for answers / information on the web to help. There is a manual that shows the registers but am a little lost on how to go about it on the mbed compiler. Would anyone be able to help or point me in the right direction please?

Thank you

Hi Peter, apologies for the delay. I've included the "mbed.h" library but the AnalogIn myinput(PA_3); doesn't seem to work. However, I've managed to take an example from the Keil IDE for this device and re-arrange the mapping for the analogue in pins and added to the mbed compiler before the main function:

Re-mapping pins for Analogue In

RCC->APB2ENR |= ( 1UL << 2); /* enable periperal clock for GPIOA */

GPIOA->CRL &= 0xFFF0000F; /* set PIN7, PIN6, PIN3 and PIN0 as analog input */

RCC->APB2ENR |= ( 1UL << 3); /* enable periperal clock for GPIOB */

GPIOB->CRL &= 0x000000FF; /* set all Pins (1 to 0) as analog input */

RCC->APB2ENR |= ( 1UL << 4); /* enable periperal clock for GPIOC */

GPIOC->CRL &= 0x00FFFFFF; /* set Pins (5 to 0) as analog input */

It seems to accept the code and now can use the AnalogIn for the other pins. I've not used PA_3 as this is for the serial IO (Serial2:RX) but the other available pins (PA_6, PA_7...) didn't work as first suggested, but the re-mapping as above worked for me so hopefully it can help others. Thank you Peter for your responses. Best Regards.

posted by Michael Fyfield 30 Oct 2014
Comment on this question

1 Answer

5 years, 2 months ago.

All pins with the physical option should be used as Analog In. If you define "AnalogIn myinput(PA_3);" PA_3 will be used as analog input. myinput.read() will return a float, myinput.read_u16() will return a an unsigned short.

Hi Peter, thank you for your response, but still having trouble. I've assigned the PA_3 as AnalogIn but having Tera Term open while flashing the .bin to the board it comes up with "pinmap not found for peripheral" and halts any other serial data from being sent (from A0 - A5: floating data with "otherinput.read()"). Taking this AnalogIn myinput(PA_3); and the myinput.read(); out allows the serial data from A0 to A5 to be sent to Tera Term. The PA_3 is capable of having AnalogIn and other pins, which have been tried but with no success...

posted by Michael Fyfield 24 Sep 2014

If I compile the "Nucleo_read_analog_value" compiler template with PA_3 it is working. Are you using the actual mbed lib ? If not please update.

posted by Peter Drescher 25 Sep 2014

You need to log in to post a question