Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


stm32f303rct6 Comparator interruption does not work

Hello!
Please help in setting interrupts. I’ve been tormented for several days. The program does not fall into interruption.

/**
******************************************************************************
* @file main.c
* @author Ac6
* @version V1.0
* @date 01-December-2013
* @brief Default main function.
******************************************************************************

  • /


  1. include “stm32f30x.h”
  2. include “stm32f30x_exti.h”
  3. include “stm32f30x_rcc.h”
  4. include “stm32f30x_gpio.h”
  5. include “stm32f30x_syscfg.h”
  6. include “stm32f30x_dac.h”



void init(void);
unsigned short count=0;

void COMP4_5_6_IRQHandler(void) {
EXTI_ClearITPendingBit(EXTI_Line30);
count++;

}

int main() {
init();
while(1) {
}
}

void init(void) {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);


GPIO_InitTypeDef gpio_init;
gpio_init.GPIO_Mode = GPIO_Mode_AN;
gpio_init.GPIO_PuPd = GPIO_PuPd_NOPULL;
gpio_init.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOB, &gpio_init);

COMP_InitTypeDef comp_init;
comp_init.COMP_InvertingInput = COMP_InvertingInput_1_4VREFINT;
comp_init.COMP_NonInvertingInput = COMP_NonInvertingInput_IO1;
comp_init.COMP_OutputPol = COMP_OutputPol_NonInverted;
comp_init.COMP_Output = COMP_Output_None;
comp_init.COMP_Hysteresis = COMP_Hysteresis_No;
comp_init.COMP_Mode = COMP_Mode_HighSpeed;
COMP_Init(COMP_Selection_COMP4, &comp_init);
COMP_Cmd(COMP_Selection_COMP4, ENABLE);


EXTI_InitTypeDef exti_init;
exti_init.EXTI_Line = EXTI_Line30;
exti_init.EXTI_LineCmd = ENABLE;
exti_init.EXTI_Mode = EXTI_Mode_Event;
exti_init.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_Init(&exti_init);

NVIC_InitTypeDef nvic_init;
nvic_init.NVIC_IRQChannel = COMP4_5_6_IRQn;
nvic_init.NVIC_IRQChannelSubPriority = 1;
nvic_init.NVIC_IRQChannelPreemptionPriority = 1;
nvic_init.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&nvic_init);
}

 

Newest Forum Posts

  1. STM32 MCU model shortlisting for Making RC remote by Palvish, 2025-07-07 15:05
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs