| Electronic Components Datasheet Search |
|
SN8F5708 Datasheet(PDF) 117 Page - SONiX Technology Company |
|
|
|||||||||||||||||||||||||||||
SN8F5708 Datasheet(HTML) 117 Page - SONiX Technology Company |
|
117 / 204 page ![]() www.sonix.com.tw SN8F5708 Series Copyright © 2019, SONiX Technology Co., Ltd. Comparator Datasheet Rev. 2.4 117 17.5 Sample Code The following sample code demonstrates how to perform CMP0 with interrupt. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 #define CM0LeChge (3 << 0) // CM0P > CM0N or CM0P < CM0N #define CM0NGreCM0P (2 << 0) // CM0P < CM0N #define CM0PGreCM0N (1 << 0) // CM0P > CM0N #define CMP0OEN (1 << 3) // CMP0 output pin enable #define CMP0Vin2V (0 << 4) // CMP0 positive Vin connect 2.0V #define CMP0Vin3V (1 << 4) // CMP0 positive Vin connect 3.0V #define CMP0Vin4V (2 << 4) // CMP0 positive Vin connect 4.0V #define CMP0VINP (3 << 4) // CMP0 positive Vin connect CM0P #define CMP0EN (1 << 7) //enable CMP0 #define CM1LeChge (3 << 0) // CM1P > CM1N or CM1P < CM1N #define CM1NGreCM1P (2 << 0) // CM1P < CM1N #define CM1PGreCM1N (1 << 0) // CM1P > CM1N #define CMP1OEN (1 << 3) // CMP1 output pin enable #define CMP1Vin2V (0 << 4) // CMP1 positive Vin connect 2.0V #define CMP1Vin3V (1 << 4) // CMP1 positive Vin connect 3.0V #define CMP1Vin4V (2 << 4) // CMP1 positive Vin connect 4.0V #define CMP1VINP (3 << 4) // CMP1 positive Vin connect CM1P #define CMP1EN (1 << 7) //enable CMP1 void CMPInit(void) { P1 = 0x00; P1M = 0xC0; // set CMP0 & CMP1 pins’ mode at pure analog pin P3CON |= 0xC0; //P36/P37 P2CON |= 0x60; //P26/P25 // configure CMP0 positive Vin = 4.0V and interrupt trigger = CM0P > CM0N // enable CMP0 and output pin CMP0M = CMP0EN | CMP0Vin4V | CMP0OEN | CM0PGreCM0N; // configure CMP1 positive Vin = CM1P and interrupt trigger = CM1P < CM1N // enable CMP1 and output pin CMP1M = CMP1EN | CMP1VINP | CMP1OEN | CM1NGreCM1P; // enable CMP0 & CMP1 interrupt IEN2 |= 0x30; IEN0 |= 0x80; //enable global interrupt } void CMP0Interrupt(void) interrupt ISRCmp0 //0xA3 { if ((IRCON2 & 0x08) == 0x08) { P16 = ~P16; IRCON2 &= 0xF7; //Clear CMP0F } } void CMP1Interrupt(void) interrupt ISRCmp1 //0xAB { if ((IRCON2 & 0x10) == 0x10) { P17 = ~P17; IRCON2 &= 0xEF; //Clear CMP1F } } |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |