In the beginning, we noted that the I/O PORT peripherals are connected to the SYSCLK bus. This means that with the help of the INV registers, you can toggle any general purpose I/O pin at the SYSCLK speed!
In the previous slide, we learned that priority level 7 vectors get the highest priority. In addition to that, the priority 7 vectors also get a dedicated shadow register set. In normal operation when the CPU is executing at priority 6 or lower, the CPU operates on a primary register set. But when a priority 7 interrupt occurs, the interrupt controller automatically switches to the shadow set and jumps to the appropriate vector. With the dedicated shadow set, the priority 7 interrupt offers faster interrupt response as compared to other priority interrupts. The reason for this is that when the priority 7 interrupt occurs, the application does not have to save the entire register set context. Instead, it only needs to save a few critical registers and start executing the user interrupt handler. Similarly, when the priority 7 interrupt handler finishes its task, the application does not have to restore the full context either. It only needs to perform few steps and immediately return to the previous execution state.
In the beginning, we noted that the I/O PORT peripherals are connected to the SYSCLK bus. This means that with the help of the INV registers, you can toggle any general purpose I/O pin at the speed!
IC32 Architecture Overview第6页最后几句
Note that the I/O PORT modules are also on the SYSCLK bus. This means that CPU can access I/O PORTs at max operating frequency
2.8 SET/CLEAR/INVERT To provide single-cycle bit operations on peripherals, the registers in the peripheral units can be accessed in three different ways depending on peripheral addresses. Each register has four different addresses. Although the four different addresses appear as different registers, they are really just four different methods to address the same physical register.
The base register address provides normal Read/Write access, the other three provide special write-only functions. 1. Normal access 2. Set bit atomic RMW access 3. Clear bit atomic RMW access 4. Invert bit atomic RMW access Peripheral reads must occur from the base address of each peripheral register. Reading from a set/clear/invert address has an undefined meaning, and may be different for each peripheral. Writing to the base address writes an entire value to the peripheral register. All bits are written. For example, assume a register contains 0xaaaa5555 before a write of 0x000000ff. After the write, the register will contain 0x000000ff (assuming that all bits are R/W bits). Writing to the Set address for any peripheral register causes only the bits written as ‘1’s to be set in the destination register. For example, assume that a register contains 0xaaaa5555 before a write of 0x000000ff to the set register address. After the write to the Set register address, the value of the peripheral register will contain 0xaaaa55ff. Writing to the Clear address for any peripheral register causes only the bits written as ‘1’s to be cleared to ‘0’s in the destination register. For example, assume that a register contains 0xaaaa5555 before a write of 0x000000ff to the Clear register address. After the write to the Clear register address, the value of the peripheral register will contain 0xaaaa5500. Writing to the Invert address for any peripheral register causes only the bits written as ‘1’s to be inverted, or toggled, in the destination register. For example, assume that a register contains 0xaaaa5555 before a write of 0x000000ff to the invert register address. After the write to the Invert register, the value of the peripheral register will contain 0xaaaa55aa.
12.2.1 CLR, SET AND INV REGISTERS(PIC32 数据手册IO部分) Every I/O module register has a corresponding CLR (clear), SET (set) and INV (invert) register designed to provide fast atomic bit manipulations. As the name of the register implies, a value written to a SET, CLR or INV register effectively performs the implied operation, but only on the corresponding base register and only bits specified as ‘1’ are modified. Bits specified as ‘0’ are not modified. Reading SET, CLR and INV registers returns undefined values. To see the affects of a write operation to a SET, CLR or INV register, the base register must be read. To set PORTC bit 0, write to the LATSET register: LATCSET = 0x0001; To clear PORTC bit 0, write to the LATCLR register: LATCCLR = 0x0001; To toggle PORTC bit 0, write to the LATINV register: LATCINV = 0x0001;