Jump to content

Oleg_Shonin

Members
  • Content Count

    735
  • Joined

  • Last visited

Community Reputation

34 Обычный

About Oleg_Shonin

  • Rank
    Завсегдатай

Электроника

  • Стаж в электронике
    Не связан с электроникой
  1. Ответ найден... не было включено тактирования конфигсис RCC->APB2ENR |= 0x4000;
  2. Разрешите продолжить тему и задать вопросик. Отладочная плата STM32F407 Discovery kit, на которой камень stm32407VG. Собственно проблема в следующем - кнопка "Пользователь" подвязана к порту PA0, и я по ней делаю прерывания... Проблема в том, что даже если указатель прерывания SYSCFG->EXTICR[0] |= 0x00; изменить, скажем, на SYSCFG->EXTICR[0] |= 0x01; то даже в этом случае прерывание происходит... Подскажите где копать, так как мне не понятно, как кнопка, которая физически впаяна в плату, прошивается как причина EXTI0 #include "stm32f4xx.h" // Device header //#include "Main.h" // Device header int n; static unsigned D; // TEMP for read value uint32_t ad [1] = {1}; //********************************************************************************************// //-----------------------------------CUSTOMER FUNCTIONS---------------------------------------// void delay(int n) { while(n>0) n--; } //-----------------------------------ACTIVATE PORTS AS INPUT/OUTPUT--------------------------// void PORTA (void) { RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;// switch on tackting PORTA GPIOA->MODER |=0x00; //32 bit for 16 inputs for 16 input 0x40000000, for 15 input 0x10000000...for 1 input 0x01. Means 01 for ech two bits if input GPIOA->OTYPER |=0x00; //16 bit for 16 inputs for 16 input. Means 0 OR 1 for ech bits if use OR not use internal resistor GPIOA->OSPEEDR |=0x00; //32 bit for 16 inputs. Means 00 for LOW speed or 01 for MEDIUM or 10 for HIGH or 11 for VERY HIGH speed GPIOA->PUPDR |=0x02; //32 bit for 16 inputs. Means 00 for no pulup/puldown resistor or 01 for pulup or 10 for puldown or 11 RESERVED } void PORTC (void) { RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN;// switch on tackting PORTC } void PORTD (void) { RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;// switch on tackting PORTA GPIOD->MODER |=0x55000000; //32 bit for 16 inputs for 16 input 0x40000000, for 15 input 0x10000000...for 1 input 0x01. Means 01 for ech two bits if input GPIOD->OTYPER |=0x00; //16 bit for 16 inputs for 16 input. Means 0 OR 1 for ech bits if use OR not use internal resistor GPIOD->OSPEEDR |=0x00; //32 bit for 16 inputs. Means 00 for LOW speed or 01 for MEDIUM or 10 for HIGH or 11 for VERY HIGH speed GPIOD->PUPDR |=0x00000000; //32 bit for 16 inputs. Means 00 for no pulup/puldown resistor or 01 for pulup or 10 for puldown or 11 RESERVED D=GPIOD->IDR; //16 bit for 16 inputs. USED ONLY for READ STATUS, which is set as INPUT GPIOD->ODR |=0x8000; //16 bit for 16 inputs for 16 input. Means 0 OR 1 for ech bits if use OR not use as output GPIOD->BSRRL |=0x00; //16 bit for 16 inputs for 16 input. Means 0 OR 1 for ech bits if use OR not use SET as OUTPUT GPIOD->BSRRH |=0x8000; //16 bit for 16 inputs for 16 input. Means 0 OR 1 for ech bits if use OR not use RESET as OUTPUT GPIOD->LCKR |=0x00; //Lock or NOT lock configuration of the port bits. IMPORTANTE: Access: 32-bit word only, read/write register //LOCK key write sequence: // WR LCKR[16] = ‘1’ + LCKR[15:0] // WR LCKR[16] = ‘0’ + LCKR[15:0] // WR LCKR[16] = ‘1’ + LCKR[15:0] // RD LCKR // RD LCKR[16] = ‘1’ (this read operation is optional but it confirms that the lock is active) // Note: During the LOCK key write sequence, the value of LCK[15:0] must not change. // Any error in the lock sequence aborts the lock. // After the first lock sequence on any bit of the port, any read access on the LCKK bit // returns ‘1’ until the next CPU reset. GPIOD->AFR[0] |=0x00;// AFRL GPIOD->AFR[1] |=0x00;// AFRH } //********************************************************************************************// //-----------------------------------System configuration controller--------------------------// void SYSCFG_INITIAL (void) { SYSCFG->MEMRMP |= 0x00;// Main Flash memory mapped at 0x0000 0000 SYSCFG->PMC |= 0x00; //For 0x00 - MII interface is selected. Foir 0x01 - RMII PHY interface is selected. } //-----------------------------------ACTIVATE EXTERNAL INTERRUPT BELONG TO ACTION-------------// void SYSCFG_INTERRUPT (void) { SYSCFG->EXTICR[0] |= 0x00;//These bits are written by software to select the source input for the EXTIx (from EXTI0-EXTI3) EXAMPLE 0000: PA[x] pin or 0001: PB[x] pin //SYSCFG->EXTICR[1] |= 0x00;//These bits are written by software to select the source input for the EXTIx (from EXTI0-EXTI3) EXAMPLE 0000: PA[x] pin or 0001: PB[x] pin //SYSCFG->EXTICR[2] |= 0x00;//These bits are written by software to select the source input for the EXTIx (from EXTI0-EXTI3) EXAMPLE 0000: PA[x] pin or 0001: PB[x] pin //SYSCFG->EXTICR[3] |= 0x00;//These bits are written by software to select the source input for the EXTIx (from EXTI0-EXTI3) EXAMPLE 0000: PA[x] pin or 0001: PB[x] pin //SYSCFG->CMPCR |= 0x00;//Compensation cell //SYSCFG->EXTICR1->EXTI0 |=0x00; //SYSCFG->EXTICR[0] = SYSCFG_EXTICR1_EXTI0_PA; } //-----------------------------------LOGIC FOR INTERRUPT ------------------------------------// void EXTI0_IRQHandler (void) { /*----------------------------------------------*/ GPIOD->BSRRH =0xF000; EXTI->PR |= 0x01; //Reset (for Event and Interrupt) for input line } //-----------------------------------SIGN UP EXTERNAL INTERRUPT TO BITS----------------------// void SET_INTERRUPT (void) { EXTI->IMR |= 0x01; // Interrupt request from line EXTI_IMR0 is not masked EXTI->EMR |= 0x01; // Event request from line EXTI_EMR0 is not masked EXTI->RTSR |= 0x01; //Rising trigger enabled (for Event and Interrupt) for input line EXTI->FTSR |= 0x01; //Falling trigger enabled (for Event and Interrupt) for input line NVIC->ISER[0] |= 0x58;// EXTI0-> EXTI Line0 interrupt-> 0x0000 0058 (from datasheet) } //-----------------------------------MAIN PROGRAMM--------------------------// int main (void) { n=4500000; PORTA(); PORTC(); PORTD(); SYSCFG_INITIAL(); SYSCFG_INTERRUPT(); SET_INTERRUPT (); while(1) { GPIOD->ODR =0xF000; GPIOD->BSRRL =0xF000; LOOP: GPIOD->BSRRH =0x1000; GPIOD->BSRRL =0x8000; delay(n); GPIOD->BSRRH =0x2000; GPIOD->BSRRL =0x1000; delay(n); GPIOD->BSRRH =0x4000; GPIOD->BSRRL =0x2000; delay(n); GPIOD->BSRRH =0x8000; GPIOD->BSRRL =0x4000; delay(n); goto LOOP; } }
×
×
  • Create New...