| Electronic Components Datasheet Search |
|
SN8F5708 Datasheet(PDF) 88 Page - SONiX Technology Company |
|
|
|||||||||||||||||||||||||||||
SN8F5708 Datasheet(HTML) 88 Page - SONiX Technology Company |
|
88 / 204 page ![]() www.sonix.com.tw SN8F5708 Series Copyright © 2019, SONiX Technology Co., Ltd. Timer 0 and Timer 1 Datasheet Rev. 2.4 88 14.7 Sample Code The following sample code demonstrates how to perform T0/T1 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 #define T0Mode0 (0 << 0) //T0 mode0, 13-bit counter #define T0Mode1 (1 << 0) //T0 mode1, 16-bit counter #define T0Mode2 (2 << 0) //T0 mode2, 8-bit auto-reload counter #define T0Mode3 (3 << 0) //T0 mode3, T0 two 8-bit counter/T1 no flag #define T0GATE (8 << 0) //T0 gating clock by INT0 #define T0ClkFcpu (0 << 0) //T0 clock source from Fcpu/12 #define T0ClkExt (4 << 0) //T0 clock source from Fosc or FRTC #define T0ExtFosc (0 << 4) //T0 clock source from Fosc #define T0ExtFRTC (8 << 4) //T0 clock source from FRTC #define T1Mode0 (0 << 4) //T1 mode0, 13-bit counter #define T1Mode1 (1 << 4) //T1 mode1, 16-bit counter #define T1Mode2 (2 << 4) //T1 mode2, 8-bit auto-reload counter #define T1Mode3 (3 << 4) //T1 mode3, T1 stop #define T1GATE (8 << 4) //T1 gating clock by INT1 #define T1ClkFcpu (0 << 4) //T1 clock source from Fcpu/12 #define T1ClkExt (4 << 4) //T1 clock source from Fosc void InitT0T1(void) { // T0/T1_Initial TH0 = 0x00; TL0 = 0x00; TH1 = 0x00; TL1 = 0x00; // T0 mode0 with gating clock by INT0, clock source from Fosc or FRTC TMOD |= T0Mode0 | T0GATE | T0ClkExT; // T0 clock source = FRTC/1 TCON0 |= T0ExtFRTC | 0x70; // T1 mode1, clock source from Fcpu/12 TMOD |= T1Mode1 | T1ClkFcpu; // Timer 0/1 enable. Clear TF0/TF1 TCON |= 0x50; // Enable T0/T1 interrupt IEN0 |= 0x0A; // Enable total interrupt IEN0 |= 0x80; P0 = 0x00; P0M = 0x03; } void T0Interrupt(void) interrupt ISRTimer0 //0x0B { //TF0 clear by hardware P00 = ~P00; } void T1Interrupt(void) interrupt ISRTimer1 //0x1B { //TF1 clear by hardware P01 = ~P01; } |
|
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 |