Skocz do zawartości

PeterQ

Użytkownicy
  • Zawartość

    5
  • Rejestracja

  • Ostatnio

Informacje

  • Płeć
    Mężczyzna
  • Moje zainteresowania:
    Elektronika, Robotyka, PLC

Osiągnięcia użytkownika PeterQ

Młodszy odkrywca

Młodszy odkrywca (3/19)

  • Za 5 postów
  • To już rok!
  • To już 5 lat!

Odznaki

0

Reputacja

  1. O! Widzę, że chłopaki poradziliście sobie z przejściem przerwania zewnętrznego na F4. Pomożecie? Co robię źle, że nie działa ono jak powinno? #include "stm32f4xx.h" //#include "stm32f4xx_exti.h" //#include "stm32f4xx_syscfg.h" //#include "misc.h" void Configure_LED(){ /*Set variables used*/ GPIO_InitTypeDef gpio; /*Enable clock for GPIOA*/ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); /*Set pin as output*/ GPIO_StructInit(&gpio); gpio.GPIO_Pin = GPIO_Pin_5; gpio.GPIO_Mode = GPIO_Mode_OUT; gpio.GPIO_OType = GPIO_OType_PP; GPIO_Init(GPIOA, &gpio); } void Configure_PC13(void) { /* Set variables used */ GPIO_InitTypeDef GPIO_InitStruct; EXTI_InitTypeDef EXTI_InitStruct; NVIC_InitTypeDef NVIC_InitStruct; /* Enable clock for GPIOC */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); /* Enable clock for SYSCFG */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Set pin as input */ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOC, &GPIO_InitStruct); /* Tell system that you will use PC13 for EXTI_Line13 */ SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource13); /* PC13 is connected to EXTI_Line13 */ EXTI_InitStruct.EXTI_Line = EXTI_Line13; /* Enable interrupt */ EXTI_InitStruct.EXTI_LineCmd = ENABLE; /* Interrupt mode */ EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt; /* Triggers on rising and falling edge */ EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling; /* Add to EXTI */ EXTI_Init(&EXTI_InitStruct); /* Add IRQ vector to NVIC */ /* PC13 is connected to EXTI_Line13, which has EXTI15_10_IRQn vector */ NVIC_InitStruct.NVIC_IRQChannel = EXTI15_10_IRQn; /* Set priority */ NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0x00; /* Set sub priority */ NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0x01; /* Enable interrupt */ NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE; /* Add to NVIC */ NVIC_Init(&NVIC_InitStruct); } /* Set interrupt handlers */ /* Handle PC13 interrupt */ void EXTI15_10_IRQHandler(void) { /* Make sure that interrupt flag is set */ if (EXTI_GetITStatus(EXTI_Line13) != RESET) { /* Do your stuff when PC13 is changed */ GPIO_ResetBits(GPIOA, GPIO_Pin_5); // turn LED off /* Clear interrupt flag */ EXTI_ClearITPendingBit(EXTI_Line13); } } int main(void) { /* System init */ SystemInit(); /*Configure LED on PA5*/ Configure_LED(); /* Configure PC13 as interrupt */ Configure_PC13(); GPIO_SetBits(GPIOA, GPIO_Pin_5); // turn LED on while (1) { } }
  2. Cześć! Widzę, że mamy podobny problem dlatego pozwolę sobie wrzucić tutaj również mój kod do przeanalizowania to może ktoś połapie wątki i wychwyci o co tu chodzi i pomoże nam obu. Próbuję wywołać przerwanie zewnętrzne przy pomocy przycisku znajdującego się na płytce NUCLEO F446RE ale tak jak u kolegi nie ma reakcji... #include "stm32f4xx.h" #include "stm32f4xx_exti.h" #include "stm32f4xx_syscfg.h" #include "misc.h" void Configure_LED(){ /*Set variables used*/ GPIO_InitTypeDef gpio; /*Enable clock for GPIOA*/ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); /*Set pin as output*/ GPIO_StructInit(&gpio); gpio.GPIO_Pin = GPIO_Pin_5; gpio.GPIO_Mode = GPIO_Mode_OUT; gpio.GPIO_OType = GPIO_OType_PP; GPIO_Init(GPIOA, &gpio); } void Configure_PC13(void) { /* Set variables used */ GPIO_InitTypeDef GPIO_InitStruct; EXTI_InitTypeDef EXTI_InitStruct; NVIC_InitTypeDef NVIC_InitStruct; /* Enable clock for GPIOC */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); /* Enable clock for SYSCFG */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Set pin as input */ GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13; GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOC, &GPIO_InitStruct); /* Tell system that you will use PC13 for EXTI_Line13 */ SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource13); /* PC13 is connected to EXTI_Line13 */ EXTI_InitStruct.EXTI_Line = EXTI_Line13; /* Enable interrupt */ EXTI_InitStruct.EXTI_LineCmd = ENABLE; /* Interrupt mode */ EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt; /* Triggers on rising and falling edge */ EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling; /* Add to EXTI */ EXTI_Init(&EXTI_InitStruct); /* Add IRQ vector to NVIC */ /* PC13 is connected to EXTI_Line13, which has EXTI15_10_IRQn vector */ NVIC_InitStruct.NVIC_IRQChannel = EXTI15_10_IRQn; /* Set priority */ NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0x00; /* Set sub priority */ NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0x01; /* Enable interrupt */ NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE; /* Add to NVIC */ NVIC_Init(&NVIC_InitStruct); } /* Set interrupt handlers */ /* Handle PC13 interrupt */ void EXTI15_10_IRQHandler(void) { /* Make sure that interrupt flag is set */ if (EXTI_GetITStatus(EXTI_Line13) != RESET) { /* Do your stuff when PC13 is changed */ GPIO_ResetBits(GPIOA, GPIO_Pin_5); // turn LED off /* Clear interrupt flag */ EXTI_ClearITPendingBit(EXTI_Line13); } } int main(void) { /* System init */ SystemInit(); /*Configure LED on PA5*/ Configure_LED(); /* Configure PC13 as interrupt */ Configure_PC13(); GPIO_SetBits(GPIOA, GPIO_Pin_5); // turn LED on while (1) { } }
  3. Powiem Ci, że próbuję korzystając z kursu dla F1 programować NucleoF4 i jest mi mega ciężko. Środowisko i konfiguracja bardzo fajnie ale dalej już gorzej. Oba mikrokontrolery różnią się od siebie obsługą na tyle, że korzystanie z kursu F1 dla F4 jest nieopłacalne. Np. teraz utknąłem na obsłudze zwykłego przerwania wywołanego naciśnięciem przycisku. Biblioteki użyte w kursie dla F1 różnią się znacznie od tych dla F4 i ciężko jest skorzystać z kodu przedstawionego w kursie. Nie chcę Cię zniechęcać, piszę tylko o moich doświadczeniach 😋 Chwila cierpliwości i pojawią się kolejne części z serii F4 😃
  4. To oczywiste 😋 Po prostu jestem ciekaw czy będę mógł czerpać wiedzę z kursu w programowaniu płytki Nucleo z mikrokontrolerem serii F4. Skoro już ją mam to czemu by nie skorzystać ?! 🙂
  5. Cześć, a czy do przejścia powyższego kursu będę mógł wykorzystać płytkę Nucleo z STM32F4? Wiem, że będzie się to wiązało z pewnymi rozbieżnościami w porównaniu do Discovery ale akurat taką sobie kupiłem 😋 Pozdrawiam
×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.