
Chapter 3
Programming
6527 Register-Level Programmer Manual
3-8
ni.com
Write (Clear Register,0x03)
//Clear filters and filter interval clock
Write (Port 0 Filter Enables, 0xFF)
//Enable filter for eight bits of Port 0
2. Set the Edge Detection Enable bits for the lines and edges you want to detect.
Write (Port 0 Rising Edge Detection, 0xF2) //Rises to detect: lines 7 down to 4 and line 1
Write (Port 0 Falling Edge Detection, 0xF1) //Falls to detect: lines 7 down to 4 and line 0
3.
Write to the Clear Register to clear any existing interrupts before you begin.
Write (Clear Register, 0x0F)
//Clear any previously set interrupt flags
4.
After all other configuration, write to the Master Interrupt Control Register to enable
interrupt generation.
Write (Master Interrupt Control, 0x01)
//Enable Interrupts
Handling Interrupts
Inside your interrupt service routine (ISR), use the Change Status Register to verify that a
change occurred using the following pseudocode example:
Read (Change Status)
//Read status to verify change occurred
Then read the value of the input lines from the Port Register:
Read (Port 0)
//Read the present state of input lines
The value you read from the Port Register indicates the present state of the input lines at the
time you execute the read. The state you read may not be the state that caused the interrupt
because the inputs may have changed after the interrupt was generated. The Port Registers do
not indicate which line changed, how many times a line changed, or whether a line rose or fell.
To clear a change notification interrupt, write to the Clear Register:
Write (Clear Register,0x08)
//Clear change detectors
Disabling Change Notification
To disable change notification, write to the Master Interrupt Control register:
Write(Master Interrupt Control,0x00)
//Disable interrupts
After disabling interrupts, you can write to any other configuration register that you want to
reprogram.