SMT32F103c8 PWMOUT PA_2

Using Mbed Studio and a STM32F103c8 I cant PWMout on PA_2. It just goes full on all the time if set “PwmOut blueled(PA_2);”
PMW out works fine for PA_0 and PA_01. PA_2 is a PWM pin on the STM32F103c8
It works fine in arduino but not Mbed for some reason.

I haven’t run into any other issues but could be from my setup? I am using NUCLEO-F103RB as the target but Deploy and debug target: STM32F103C8 (Keil.STM32F1xx_DFP.2.3.0) with debug flags “–target STM32F103C8 --erase=chip --frequency 1800000 --pack ‘c:\Users\garne\AppData\Local\Mbed Studio\mbed-studio-tools\cmsis-packs\Keil.STM32F1xx_DFP.2.3.0-small.pack’ -O connect_mode=under-reset”

I just didn’t see any other way to do the stm32F103c8 easily in MBed and I like the CAN bus API for mbed.

Hello,

I do not know what a version of MbedOs do you use, but pins PA_2 and PA_3 are cutout from ADC peripheral on Nucleo-F103RB in pin map because they are already connected to STDIO UART TX/RX of the ST-Link.

Try to check

BR, Jan

Hi
I don’t know if you are using Bluepill board, but PA2 and PA3 are used for CONSOLE:

Jerome

Can I disable Console? This isn’t on a dev board its a custom PCB. I designed it while working on the project in arduino IDE but I like the CAN API in mbed better.

You can remap / redirect it to your pins

Or disable it in mbed_app.json

{
    "target_overrides": {
        "*": {
            "target.console-uart": false
        }
    }
}

Steps bellow are required only for Nucleo-F103 not for BluePhill target.
You will also probably need to uncomment the pin in PeripheralPins.c line 58 for ADC, how I posted in previous post.
Or for testing you can try to add this line to your code, that will override the Peripheral Pins.c.

extern const PinMap PinMap_ADC[] = {
    {PA_0,       ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, 
    {PA_1,       ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, 
	{PA_2,       ADC_1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)},
    //rest of ADC pins
	{NC, NC, 0}
};
AnalogIn ain(PA_2);

BR, Jan

Worked like a dream. Thanks!