Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] How do I make that I would have in pwm port and digital entry same frequency

Status
Not open for further replies.

dor8

Junior Member level 1
Joined
Mar 24, 2014
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
114
I use PWM port that connection to DIGITAL input and from digital input (with interrupt-B5) I take another digital output controller (C0), it's because I need to switch fourth transistors and this technique should work for me.
(Attached picture of the connection)
in duty Cycle I see that I flip between the PWM and digital port (it's like I want to), but I do not know why frequency is not the same- 50KHZ.
in attached Picture we see that in Yellow I get the frequency I want (50KHZ ) and in blue I gut a completely different frequency (4 KHZ) - I want them to be the same frequency, how can I do it?
Also attached to the code

Code:
/* Main.c file generated by New Project wizard

 *[B] Processor: PIC16F886[/B]
 [B]* Compiler:  HI-TECH C for PIC10/12/16[/B]
 */

#include <htc.h>


             void interrupt IOC_ISR(void)
        {
	      if (RB5==1) 
{
			RC0=0; //duyt cycle of 0.65
}
              else 
{
RC0=1;
}

		        RBIF=0;
	        }
void main()
        {

        TRISC = 0 ;                     // set PORTC as output
        TRISB=0b11111111;
        PORTC = 0 ;                     // clear PORTC
		ANSEL=0;
		ANSELH=0;   
OSCCON = 0b01100101; //int oscilator- 4Mhz

PR2 = 0b00000100 ; // 50KHZ freq
T2CON = 0b00000101 ; //50KHZ freq
CCPR1L = 0b00000001 ; //duyt cycle of 0.35
CCP1CON = 0b00111100 ; //duyt cycle of 0.35

GIE= 1;
RBIE=1; // eneble port b
RBIF=0;
IOCB=0b00110000; // INTERRUPT ON CHANGE REGISTER 
 while (1){
    RB5=CCPR1; 
 }


	 
    
        
}





חיבור.JPGUntitled.jpg
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top