Old 6th March 2017, 02:11   #1
Junior Member
Join Date: Nov 2016
Posts: 2
Need Help With Pwm In Pic16f628a

#define XTAL_FREQ 20MHZ /* Crystal frequency in MHz */
#include <pic16f628a.h>
#include <xc.h>
#include "delay.h"

#pragma config FOSC = HS // Oscillator Selection bits (XT oscillator: Crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
#pragma config BOREN = OFF // Brown-out Detect Enable bit (BOD disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB4/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Data memory code protection off)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)

#define r1 RA0
#define r2 RA1
#define ll1 RA2
#define l2 RA3
#define buzzer RB7
#define t1 RB4
#define t2 RB5
int pattern,off;
void System_init(void) {
TRISA = 0X00;
TRISB = 0b00000011;
CCP1CON = 0b00001100;
PR2 = 249;
T2CON = 0b00000100;
void main(void) {
while (1) {
if (pattern == 1) {
r1 = ~r1;
r2 = ~r2;
l1 = 0;
ll2 = 0;


if (pattern == 2) {

CCPR1L= 50;
CCPR1L= 240;

this is my PWM program in PIC16F628A(http://www.kynix.com/uploadfiles/pdf...I2fP_95522.pdf). Everything working fine
But when controller running pattern=1 also i'm getting output from PWM...

I don't know what is the problem with my code.
faceu is offline   Reply With Quote
Old 23rd March 2017, 05:15   #2
Join Date: Mar 2017
Posts: 3
Play the best strategy for baccarat card games
wxiao is offline   Reply With Quote
Go Back   Winamp & SHOUTcast Forums > Community Center > General Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump