Interrupt on in B1? ON Bluepill STM32F103

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

Interrupt on in B1? ON Bluepill STM32F103

#1 Post by corado » 11 Oct 2023 19:25

Hallo,
does anybody have an Example, how I can initialize an external Interrupt with STM32F103 Bluepill on PIN B1?

At this moment I try with this

Code: Select all

procedure Event(); iv IVT_INT_EXTI1; ics ICS_AUTO;
begin
GPIOC_ODR := not GPIOC_ODR; // Toggle PORTC
delay_ms(100);
end;

Code: Select all

RCC_APB2ENR.AFIOEN := 1;              // Enable clock for alternate pin functions
  AFIO_EXTICR3 := 0x0100;               // PB as External interrupt
  AFIO_EXTICR1 := 0x0001;               // PB as External interrupt
  EXTI_RTSR :=  0x00000400;             // Set interrupt on Rising edge
  EXTI_IMR := EXTI_IMR or 0xFFFF;   // Set mask
  NVIC_IntEnable(IVT_INT_EXTI1);    // Enable External interrupt

  EnableInterrupts();                   // Enables the processor interrupt.

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

Re: Interrupt on in B1? ON Bluepill STM32F103

#2 Post by corado » 11 Oct 2023 22:11

Now it works

Code: Select all

program STM32F103V8_16x2;
{ Declarations section }
{ Declarations section }
procedure ExternerInterrupt(); iv IVT_INT_EXTI1; ics ICS_AUTO;
Begin
DisableInterrupts();
GPIOC_ODR := 0x0000; // Setze Port C auf 0;
EXTI_PR := 0x0000001A;  //Pending register zurücksetzen
EnableInterrupts();
end;
Begin
 GPIO_Digital_Input(@GPIOB_BASE, _GPIO_PINMASK_ALL);
 GPIO_Digital_Output(@GPIOC_BASE, _GPIO_PINMASK_ALL); // Set PORTC as digital output
 GPIO_Alternate_Function_Enable(@_GPIO_MODULE_SWJ_JTAGDISABLE );
 GPIO_Analog_Input(@GPIOA_BASE, _GPIO_PINMASK_1 );
  GPIOC_ODR := 1 SHL 13; Schalte LED am Port PC.13 aus (Bluepill)
//*******************************
  GPIOB_CRL := 0xFFFFFFFF; //Port configuration register low
  RCC_APB2ENR.AFIOEN := 1;              // Enable clock for alternate pin functions
   AFIO_EXTICR1 := 0x00000010;               // PB.1 as External interrupt
  EXTI_RTSR :=  0xFFFFFFFF;             // Set interrupt on Rising edge #######  not ready yet, FFFFFF is wrong, but it work
  EXTI_IMR :=  0xFFFFFFFF;   // Set mask ####### not ready yet, FFFFFF is wrong, but it work
  NVIC_IntEnable(IVT_INT_EXTI1);    // Enable External interrupt
  EnableInterrupts();                   // Enables the processor interrupt.
   //clk := Clock_MHz();
{ Main program }
 
While TRUE DO
 begin
 
end.

Post Reply

Return to “mikroC PRO for ARM General”