cc2530 of I / O interrupts

Universal I / O interrupt

cc2530 the CPU 18 interrupt sources, each interrupt can be enabled and controlled.

18 interrupt sources of priority

18 interrupt sources are divided into six groups, each group has three interrupt sources, the interrupt priority may be implemented by configuring the corresponding registers

Interrupt source packet
number of the interrupt

  • IPG0 REFRR RF DMA
  • IPG1 ADC T1 P2INT
  • IPG2 URX0 T2 UTX0
  • IPG3 URX1 T3 UTX1
  • IPG4 ENC T4 P1INT
  • IPG5 ST P0INT WDT

Interrupt priority register by IP0 and IP1 to achieve, digital IP1_X IP0_x represented about big, the higher the priority

  • IP1_X IP0_X priority
  • 000 (lowest priority)
  • 0 1 1
  • 1 0 2
  • 113 (highest priority)

When IP1_X and IP0_X the X represents the group name interrupt priority group, namely IPG0 ~ IPG5, set the lowest priority of the highest priority, 0 of 3
cases:

//设置IPG3的优先级别最高
IP1_IPG3=1;
IP0_IPG3=1;
//设置IPG0的优先级别最低
IP1_IPG1=0;
IP1_IPG0=0

If the priority occur simultaneously in the same group, we will have a decision this order is interrupted turns probe order. (The book has a table, and hold the first, P.59 in the book)

I / O interruption

Enabling position facing common I / O setting inputs can be used to generate an interrupt, and the general-purpose I / O interruption may be provided which triggers a mode needs to be set when the interrupt occurs at the interrupt pin 1, Port Enable bit setting register:

  • P0 port interrupt enable bit --IEN1.P0IE
  • P1 port interrupt enable bit --IEN2.P1IE
  • p2 port interrupt enable bit --IEN2.P2IE
Here we must note, IENx interrupt enable register is enabled throughout the port, not to a particular pin.

Interrupt enable register P0 IEN1 control ports, timers 1 to 4 and the DMA interrupt enable and disable, if desired a particular interrupt is enabled, just IEN1 corresponding bit is set to 1.

  • Interrupt enable register IEN1
  • Bit Name Reset Description
  • 7: 6 --- 00 Reserved
  • 5 P0IE 0 0 interrupt enable port
  • 4 T4IE 0 Timer 4 interrupt enable
  • 3 T3IE 0 Timer 3 interrupt enable
  • 2 T2IE 0 Timer 2 interrupt enable
  • 1 T1IE 0 Timer 1 interrupt enable
  • 0 DMAIE 0 DMA interrupt enable

IEN1 interrupt settings

//设置P0端口中断使能
IEN1 |= 0x20;
  • Interrupt enable register IEN2
  • Bit Name Reset Description
  • 7: 6 --- 00 Reserved
  • 5 WDTIE 0 Watchdog timer interrupt enable
  • 4 P1IE 0 Port 1 interrupt enable
  • 3 UTX1IE 0 USART1 TX Interrupt Enable
  • 2 UTX0IE 0 USART2 TX Interrupt Enable
  • 1 P2IE 0 Port 2 Interrupt Enable
  • 0 RFIE 0 RF general interrupt enable

IEN2 interrupt settings

//设置P1和P2端口中断使能
IEN2|=0x12;

IEN1 enable register control the P0 port interrupt enable, IEN2 interrupt control register P1 and port P2 port interrupt enable.

A control pin Interrupt Enable PxIEN (x = 0,1,2)
//设置P0_5中断使能
P0IEN |= 0x20;

//设置P0端口中断使能
IEN1 |= 0x20;
Control interrupt is triggered by the rising or falling edge trigger PICTL
  • Interrupt trigger mode register PICTL
  • Bit Name Reset Description
  • 7 PADSC 00 controls I / O pins in the drive capability of the output mode
  • 6: 4 --- 000 Reserved
  • 3 P2ICON 0 interrupt input of the mode of the port P2.4 ~ P2.0 Configuration 2, the 2-bit input ports of all the P2.4 ~ P2.0 selection conditions 0 interrupt request is a rising edge
  • Interrupt configuration P1.7 ~ P1.4 port 2 P1ICONH 0 Input mode 1, all the bit interrupt input port 1 is selected P1.7 ~ P1.4 rising edge request condition 0
  • Interrupt configuration 1 P0ECONL 0 P1.4 ~ P1.0 port 1 input mode, the input bit is 1, all ports P1.4 ~ P0.0 selection conditions 0 interrupt request is a rising edge
  • 0 P0ICON interrupt configuration P0.7 ~ P0.0 input port 0 of the mode 0, all of the bit 0 of the interrupt input port P0.7 ~ P0.0 condition selected request is a rising edge 0
//设置P0_5下降沿触发中断
PICTL |= 0x01;

The total interrupt EA

//打开总中断
EA=1;

Interrupt flag register PxIFG (x = 0,1,2)

After the I / O interrupt occurs, the corresponding bit in the interrupt flag register is automatically set to 1

//判断端口P0是否发生中断
if(P0IFG>0)
{

}
//判断P0_5是否发生中断
if(P0IFG&0x20)
{
;

    
}

To set interrupt settings from small to large direction, starting with the pin, and then to the port, to the total interruption

Write a method CC2530 interrupt handler

#pragma vector=<中断向量>
__interrupt void <函数名称>(void)       //这里的开头是两个下划线
{

    //函数体


}

Guess you like

Origin www.cnblogs.com/longbaoshushu/p/12072532.html