在线时间145 小时
UID3256146
注册时间2016-3-29
NXP金币27
TA的每日心情 | 衰 2022-6-3 10:27 |
---|
签到天数: 131 天 连续签到: 1 天 [LV.7]常住居民III
金牌会员
 
- 积分
- 1611
- 最后登录
- 2022-6-26
|
本帖最后由 nothingelse 于 2018-12-19 11:58 编辑
   求大神指点呀我这个程序搞了好几天了也没明白为啥没进中断
- 希望大神来帮帮我这个菜鸡[code]
- #define GPIO_PIN_MASK 0x1Fu
- #define GPIO_PIN(x) (((1)<<(x & GPIO_PIN_MASK)))
- #ifndef KEIL
- #define EnableInterrupts asm(" CPSIE i");
- #else
- #define EnableInterrupts __enable_irq()
- #endif
- /*!< Macro to disable all interrupts. */
- #ifndef KEIL
- #define DisableInterrupts asm(" CPSID i");
- #else
- #define DisableInterrupts __disable_irq()
- #endif
- #include "MKL27Z644.h" // NXP::Device:Startup
- #include "SEGGER_RTT.h"
- #include "delay.h"
- int main(){
- int i = 0;
- /*clear the rtt window*/
- SEGGER_RTT_printf(0,"%s",RTT_CTRL_CLEAR);
- SEGGER_RTT_printf(0,"ledTest\r\n");
- /*Turn on portA and portB clocks*/
- SIM->SCGC5 |= SIM_SCGC5_PORTA_MASK|SIM_SCGC5_PORTB_MASK;
-
- /*Set pinA1 as gpio*/
- PORTA->PCR[1] = PORT_PCR_MUX(0b001);
- /*Set pinA2 as gpio*/
- PORTA->PCR[2] = PORT_PCR_MUX(0b001);
-
-
- /*Configures the portA pin1 and portA pin2 as output .*/
- GPIOA->PDDR = GPIO_PDDR_PDD(GPIO_PIN(1) )|GPIO_PDDR_PDD(GPIO_PIN(2));
-
- /*Set pinB0 as gpio and enable irq on falling-edge*/
- PORTB->PCR[0] &= ~PORT_PCR_MUX_MASK;
- PORTB->PCR[0] = PORT_PCR_MUX(0b001)|PORT_PCR_IRQC(0b1010)|
- PORT_PCR_PE(1)|PORT_PCR_PS(1);
-
- /*Configures the portB pin0 as input .*/
- GPIOB->PDDR = GPIO_PDDR_PDD(0<<0);
- NVIC_EnableIRQ(PORTB_PORTC_PORTD_PORTE_IRQn);
- NVIC_SetPriority(PORTB_PORTC_PORTD_PORTE_IRQn,4);
-
-
- EnableInterrupts
- PORTB->ISFR |=1<<0;
-
- while(1){
-
- SEGGER_RTT_printf(0,"%s loopping \t %s %d \r\n",
- RTT_CTRL_TEXT_GREEN,
- RTT_CTRL_TEXT_BRIGHT_RED,
- i++);
- /*Toggle pinA1*/
- GPIOA->PTOR = GPIO_PTOR_PTTO(GPIO_PIN(1));
- /*Toggle pinA2*/
- /*if(GPIOB->PDIR==GPIO_PDIR_PDI(0<<4) ){
- GPIOA->PTOR = GPIO_PTOR_PTTO(GPIO_PIN(2));
- SEGGER_RTT_printf(0,"not irq \r\n");
- }*/
- _Delay(10);
-
- }
-
- }
- void PORTB_PORTC_PORTD_PORTE_IRQHandler() {
- if(PORTB->ISFR & (1<<0)){
- SEGGER_RTT_printf(0,"irq \r\n");
- PORTB->ISFR |=1<<0;
- GPIOA->PTOR = GPIO_PTOR_PTTO(GPIO_PIN(2));
-
- }
- }
复制代码
project01_with_irq.zip
(450.66 KB, 下载次数: 5)
|
|