![]() PWM Period = (PR2 +1) * 4Tosc * TMR2 Prescale Value It is calculated by means of the following equation: The PWM output pulse period (T) depends on the value stored in the PR2 register of the Timer2. The CCP1IF flag bit will be simultaneously set. When a match occurs, the logic state of the RC2/CCP1 output pin may be changed, which depends on the state of bits in the control register (CCP1M3 - CCP1M0). In this mode, the value stored in the CCP1 register is constantly compared to the value stored in the TMR1 timer register. ![]() ' CCP1 MODULE IS SIMULTANEOUSLY SWITCHED ON MOVWF CCP1CON ' NEW VALUE IS LOADED INTO THE CONTROL REGISTER MOVLW XX ' NEW PRESCALER MODE IS SELECTED 'CCP1 MODULE IS SIMULTANEOUSLY SWITCHED ON Let's do it in mikroBasic.ĬLRF CCP1CON ' CONTROL REGISTER IS CLEARED MOVWF CCP1CON 'NEW VALUE IS LOADED INTO THE CONTROL REGISTER It is advisable to use the following program sequence written in assembly language:ĬLRF CCP1CON 'CONTROL REGISTER IS CLEARED To prevent this, the CCP1 module should be temporarily switched off prior to changing the prescaler rate. In order to prevent this, both the bit enabling the CCP1IE interrupt and the CCP1IF flag bit should be cleared prior to making any change in the CCP1CON control register.Īn unwanted interrupt may also be generated when switching from one prescaler rate to another. When the CCP1 module exits the capture mode, an unwanted capture interrupt may be generated. If the CCP1IE bit of the PIE1 register is set when it happens, an interrupt occurs. The CCP1IF flag bit is set when capture is made.
0 Comments
Leave a Reply. |