![](/images/new-backgrounds/1300294/30029475x1.webp)
14. OPTOCOUPLER OPERATION
The POL jumper on jumper block J6 selects the logic polarity of the 4 register bits
|
| ||
POL jumper | POL bit | Vin < 1.5VDC | Vin > 3VDC |
Out | 0 | 0 | 1 |
In | 1 | 1 | 0 |
To enable edge detection on any optocoupler, set the corresponding OENn bit to 1, and then select the desired edge polarity with POLn. POLn = 0 selects falling edge, and POLn = 1 selects rising edge. NOTE: The edge polarity is determined with respect to the polarity selected with the POL jumper. If the POL jumper is in, an input voltage change from 0V to 3V is considered a falling edge, not a rising edge.
Whenever you read the optocoupler logic level data
The board may also be programmed to generate interrupts when any selected edge occurs. To enable interrupts on edge detection, set the OINTE bit in Base + 11. when OINTE = 1, any edge programmed in the above manner will generate an interrupt and set the OINT bit in Base + 11. The interrupt routine reads the data by reading from Base + 7, and then it clears the interrupt request by writing a 1 to the CLRO bit in Base + 11.
NOTE:
Procedure for enabling interrupts on selected edges
1.Select the desired input channel(s) by setting OENn = 1 for each one to be detected.
2.Select the desired edge polarity for each enabled channel by setting POLn appropriately. NOTE: Steps 1 and 2 are done together with a single write operation to Base + 6.
3.Enable optocoupler interrupts by setting the OINTE bit in Base + 11.
4.When an interrupt occurs, read the edge and logic level data from Base + 7.
5.After reading the edge and logic data, write a 1 to the CLRO bit in Base + 11 to clear the interrupt request.
6.When interrupt activity is no longer needed, write a 0 to the OINTE bit to disable optocoupler interrupts.
Page 38 |