Bluepill Port B3 and Port B4

General discussion on mikroPascal PRO for ARM.
Post Reply
Author
Message
corado
Posts: 399
Joined: 28 Mar 2009 11:03

Bluepill Port B3 and Port B4

#1 Post by corado » 26 Sep 2023 18:27

How can I use GPIO B3 and B4?

I found this
GPIO_Alternate_Function_Enable(@_GPIO_MODULE_SWJ_JTAGDISABLE );

It works, with B3 but B4 ist invertet?


What's wrong?

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: Bluepill Port B3 and Port B4

#2 Post by IvanJeremic » 28 Sep 2023 11:56

Hi,

I have researched it for a bit and it seems that the PB4 pin won't work properly as a AFIO pin until first enable the clock on it.

Try using GPIO_Clk_Enable.

Regards,

Ivan.

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: Bluepill Port B3 and Port B4

#3 Post by corado » 28 Sep 2023 16:01

This works

Code: Select all

program STM32F103_Bluepill;
{ Declarations section }
{ Declarations section }
begin
 //SWJ_CFG0_bit:=0;
 //SWJ_CFG1_bit:=1;
 //SWJ_CFG2_bit:=0;
 GPIO_Digital_Output(@GPIOB_BASE, _GPIO_PINMASK_ALL); // Set PORTB as digital output
 GPIO_Alternate_Function_Enable(@_GPIO_MODULE_SWJ_JTAGDISABLE );
GPIOB_ODR:=0x0000;
While TRUE DO
 begin
 { Main program }
   GPIOB_ODR := not GPIOB_ODR; // Toggle PORTB
   delay_ms(1000);
 end;
end.

Post Reply

Return to “mikroPascal PRO for ARM General”