SlideServe
Menu
Préférences
© SlideServe · v2026

Configuring Simple Output Compare Modes in MikroC for dsPIC30F Series

alika avatar
10 diapositives · 244 Views · Aug 21, 2014

This guide provides detailed instructions on configuring the simple output compare modes for the dsPIC30F4011/4012 microcontrollers using MikroC. It outlines the various Output Compare Match modes available, including the methods to generate single and continuous output pulses. By understanding the OCxCON settings and the associated OCxR register configurations, users can effectively control the I/O pin states based on timer comparisons. Ideal for embedded systems developers, this resource is designed to streamline the implementation of output control features in your projects.

Configuring Simple Output Compare Modes in MikroC for dsPIC30F Series - slide 1
01 / 10Configuring Simple Output Compare Modes in MikroC for dsPIC30F Series
1 / 17

Télécharger la présentation

Configuring Simple Output Compare Modes in MikroC for dsPIC30F Series
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  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; • }