lundi 13 mars 2017

NVIC Interrupt not working on stm32f103

I have written the following code to control an led with a switch connected at B3 configured as AFIO, But it seems there is a problem with the nvic functions, please how should they be used ....

#include "stm32f10x.h"

int main()
{
// ENABLING CORRESPONDING CLOCKS
RCC->APB2ENR |= 0X000D;
RCC->APB1ENR |= 0X0001;

//CONFIGURING GPIO PORTS -- PIN 3 CONFIGURED AS AFIO PUSH/PULL AND PIN4 SET UP AS GPIO OUTPUT
GPIOA->CRL = 0X00B3B000; 
GPIOB->CRL = 0X0000B000;

//PA6 IS SET AS EVENT OUTPUT PORT
AFIO->EVCR |= 0X0086;

//PB3 SET AS INPUT PORT AFIO_EXTICR1
AFIO->EXTICR[1] |= 0X1000 ;

//SELECTING RISING TRIGGERS
EXTI->RTSR = 0X0008 ;

// UNMASKING INTERRUPT SIGNAL AT EXTI3
EXTI->IMR |= 0X0008 ;   

// UNMASKING EVENT SIGNAL AT EXTI6
EXTI->EMR |= 0X0040 ;   

GPIOA -> ODR=0X0010;



    NVIC_InitTypeDef NVIC_InitStructure;
  NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn; //Enable keypad external         interrupt channel
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x02; //Priority 2, 
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02; //Sub priority 2
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //Enable external     interrupt channel 
  NVIC_Init(&NVIC_InitStructure);  


    }

Aucun commentaire:

Enregistrer un commentaire