program Test_mit_STM32F103CB; var Led_1 : sbit at GPIOA_ODR.B9; Led_2 : sbit at GPIOA_ODR.B10; Led_3 : sbit at GPIOA_ODR.B11; Led_4 : sbit at GPIOA_ODR.B12; Led_5 : sBit at GPIOC_ODR.B13; Ereignis : sBit at GPIOA_IDR.B1; takt : sBit at GPIOA_ODR.B9; Wert : byte; x : byte; var Timer_ZZ : DWord; Inter_ZZ : LongInt; txt_LI : array[11] of char; messen_Flag : boolean; Stop_Flag : boolean; { Declarations section } procedure Mess(); iv IVT_INT_EXTI1; ics ICS_AUTO; begin EXTI_PR.B1 := 1; // clear flag inc(Inter_ZZ); Led_3 := Not Led_3; end; procedure InitTimer3(); begin RCC_APB1ENR.TIM3EN := 1; TIM3_CR1.CEN := 0; TIM3_PSC := 0; TIM3_ARR := 7999; NVIC_IntEnable(IVT_INT_TIM3); TIM3_DIER.UIE := 1; TIM3_CR1.CEN := 0; end; procedure Timer3_interrupt(); iv IVT_INT_TIM3; begin TIM3_SR.UIF := 0; Led_2 := not Led_2; if Timer_ZZ >= 100 then Takt := 0 // messung stoppen else inc(Timer_ZZ); end; Procedure messen; Begin Uart2_Write_Text(' - messen -'); Uart2_write(10); TIM3_CR1.CEN := 1; // Start timer Timer_ZZ := 0; Takt := 1; // Nessung freigeben While Takt = 1 do Begin end; // warten bis 100ms vorbei sind TIM3_CR1.CEN := 0; // Stop Timer LongIntToStr(Inter_ZZ, txt_LI); Uart2_Write_Text(txt_LI); Uart2_Write(10); messen_Flag := false; end; Procedure _init; Begin UART2_Init_Advanced(115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, @_GPIO_MODULE_USART2_PA23); // Uart1 für ESP201 Delay_ms(100); // Wait for UART module to stabilize Uart2_Write_Text('Start: Test mit STM32F103CB '); Uart2_write(10); GPIO_Digital_Output(@GPIOA_BASE, _GPIO_PINMASK_9 or _GPIO_PINMASK_10 or _GPIO_PINMASK_11 or _GPIO_PINMASK_12); GPIO_Digital_Output(@GPIOC_BASE, _GPIO_PINMASK_13); // STAT Led GPIO_Set_Pin_Mode(@GPIOA_BASE, _GPIO_PIN_1, _GPIO_CFG_MODE_Input or _GPIO_CFG_PULL_UP); // Interrupt eingang RCC_APB2ENR.AFIOEN := 1; // Enable clock for alternate pin functions AFIO_EXTICR1 := 0x00000000; // external interrupt auf PA1 EXTI_RTSR := 0x00000000; // 0x00000000; PA1 // Set interrupt on Rising edge (none) EXTI_FTSR := 0x00000002; // 0x00000002; PA1 // Set Interrupt on Falling edge PA1 EXTI_IMR := 0x00000002; // 0x00000002; PA1 // Set mask (PA1) NVIC_IntEnable(IVT_INT_EXTI1); // Enable External interrupt EnableInterrupts(); initTimer3; end; begin { Main program } _init; messen_Flag := true; while TRUE do Begin if messen_Flag then messen; Led_4 := not Led_4; Delay_ms(1000); end; end.