1 / 10

C Examples 6

C Examples 6. Download Links. MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference. 13.2 Simple Output Compare Match Mode

alika
Download Presentation

C Examples 6

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. C Examples 6

  2. Download Links • MPLAB IDE • dsPIC30F4011/4012 Data Sheet • dsPIC30F Family Reference Manual • MikroC • MikroC Manual • MikroC Quick Reference

  3. 13.2 Simple Output Compare Match Mode When control bits, OCM<2:O> (OCxCON<2:O>) 001, 010 or 011, the selected output compare channel is configured for one of three simple Output Compare Match modes: Compare forces I/O pin low Compare forces I/O pin high Compare toggles I/O pin The OCxR register is used in these modes. The OCxR register is loaded with a value and is compared to the selected incrementing timer count. When a compare occurs, one of these Compare Match modes occurs. If the counter resets to zero before reaching the value in OCxR, the state of the OCx pin remains unchanged.

  4. 13.3.1 SINGLE OUTPUT PULSE MODE / CONTINUOUS OUTPUT PULSE MODE For the user to configure the module for the generation of a single output pulse, the following steps are required (assuming timer is off): Determine instruction cycle time TcY. Calculate desired pulse width value based on TcY. Calculate time to start pulse from timer start value of Ox0000. Write pulse width start and stop times into OCxR and OCxRS Compare registers (x denotes channel 1, 2 N). Set Timer Period register to value equal to, or greater than, value in OCxRS Compare register. Set OCM<2:O> 100. Enable timer, TON (TxCON<15>) 1. To initiate another single pulse, issue another write to set OCM<2:O> 100. / Set OCM<2:O> 101.

  5. OC1CON=0x2005

  6. T2CON=0x8000

  7. 5 MHz Oscillator • void main() • { • T2CON=0x8000; • PR2 = 3; • OC1R = 0; • OC1RS = 2; • OC1CON=0x2005; • }

  8. 40 kHz Oscillator • void main() • { • T2CON=0x8000; • PR2 = 499; • OC1R = 0; • OC1RS = 250; • OC1CON=0x2005; • }

More Related