1 / 10

Self study Timer0 assessment intro

Self study Timer0 assessment intro. Explain in detail how to use Timer0 module as timer. What you need to know?. At least: Reference Manuals for the mid-range MCU Family Section 11=> study 11.1, 11.2, 11.3, 11.6,

cleave
Download Presentation

Self study Timer0 assessment intro

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Self study Timer0 assessment intro Explain in detail how to useTimer0 module as timer.

  2. What you need to know? At least: • Reference Manuals for the mid-range MCU FamilySection 11=> study 11.1, 11.2, 11.3, 11.6, • Data sheet PIC16F684=>study 5 until 5.1.2 includedYou are using the C-language, so it is not necessary to understand the macro instruction in detail.

  3. At the least the next topics: • fig 11.6 (sheet 4) • Limitation • Only the timer mode • Not the Watch dog mode or counter mode • Registers/Bits • TMR0 • T0CS • PSA • T0IF flag • Prescaler • Range of delays • Code snip example (1) and (2) (sheet 5 and 6)

  4. From Reference Manuals for the mid-range MCU Family(document 33023a)

  5. Example (1)code snippolling of the T0IF flag register /* Example of polling the T0IF flag (on overflow) A delay of multi * 0.256 msec; param uns8 multi <=0xFF */ void delayPolling(uns8 multi) { TMR0=0; //clear timer T0CS=0; //OPTION_REG.5 see data sheet PSA =0; //OPTION_REG.3 see data sheet OPTION_REG &=0b.1111.1000; //bit 2-0 prescaler ??? OPTION_REG |=0b.0000.0111; //bit 2-0 prescaler ??? //prescaler 1:256, Fosc/4 =1 MHz=> 3906 KHz=> 0.256 msec TMR0= 255-multi+1; //Explane! T0IF=0; //clear overflow flag while (T0IF!=1)/*wait loop*/ ; T0IF=0; }

  6. Example (2)code snip polling of the TMR0 register /* * A delay of milliSec msec; * param uns16 milliSec * CC5X compiler C notation */ void delay(uns16 milliSec) { uns8 next=0;//next is a cyclic counter (0-255) TMR0=0; //clear timer T0CS=0; //OPTION_REG.5,see data sheet PSA=0; //OPTION_REG.3,see data sheet OPTION_REG &=0b.1111.1000;//bit 2-0 prescaler OPTION_REG |=0b.0000.0010;//bit 2-0 prescaler //result prescaler 1:8 4Mhz=Fosc => 125 kHz=> 8 micro sec TMR0=1;//compensation for 2 instructions see data sheet do{ next +=125; //8*125=> 1 msec while (TMR0 != next) /*wait loop*/; milliSec-=1; } while(milliSec!=0); }

More Related