STM32F3 Comparator Interrupt not Generating
HI All,
I Have the STM32F302R8. I am using comparator 2. What I want to do is have DACH1 feed a value to the inverting input and have PA7 connected to the non inverting input. For now, I am just wanting to generate an interrupt to get things working the I want tohook it up to TIM 1.
So I have my DAC initalized and I am seeing data on the output register:
int init_DAC ()
{
RCC->APB1ENR |= RCC_APB1ENR_DAC1EN; // Enabling DAC Clcok
DAC->CR |= DAC_CR_EN1; // Enabling DAC Channel 1
return (0);
}I am here intializing the comparator:
So I enable it (with your help) I set up pin PA7 in analog mode. I select inverting input as DAC_CH1 (I am assuming piin PA4 doesnt need to be set at all since I am using internal DAC). I am closing the switch to enable PA7 signal to go through (window mode) and selecting output polarity as high.
I am enabling the COMP2 interrupt and enabling the comparator. I am also putting an arbitrary value in the DAC register to get the setpoint.
int init_COMP2()
{
// Setting the SYSCFG to enable a clock source for the comparator
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN;
RCC->AHBENR |= RCC_AHBENR_GPIOAEN; // Enabling Port A clock
GPIOA->MODER |= (1<<14) | (1<<15); // Configure PA7 as analog mode
COMP2->CSR |= (1<<6); //Selecting inverting input as DAC1_CH1
COMP2->CSR |= (1<<9); //Closing the switcch to connect PA7 to comparator non invering input (window mode)
//COMP2->CSR |= (1<<10); //Selecting Timer 1 break input as the output of the comparator (NEED TO VERIFY THIS)
//COMP2->CSR |= COMP2_CSR_COMP2BLANKING_0; //Selecting timer 1 OC5 as blanking source (NEED TO VERIFY THIS)
COMP2->CSR |= (1<<30); //Selcting output as high
NVIC_EnableIRQ(COMP2_IRQn); // Enabling COMP2 interrupt
DAC->DHR12R1 = 2000; // Pitting value in DAC
COMP2->CSR |= COMP2_CSR_COMP2EN; //Enabling Comparator
// Keep in mind that there is a comaptor lock function to disable changing of register for saftey and current limits. This will not be used in the double pulse test
return (0);
}Finally I have declared the ISR. Just setting the variable there.
void COMP1_2_IRQHandler(void)
{
COMPINT = true;
}However when I connect an external potentiometer to PA7 and vary it, the ISR never executes.
Any help pls?
Thanks
