CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

using ordinary PWM in 16F690 which contain ECCP

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
vinu
Guest







using ordinary PWM in 16F690 which contain ECCP
PostPosted: Wed Sep 13, 2006 10:06 pm     Reply with quote

Dear Sir,

Anyone give an example for using ordinary PWM (single output from p1A ) when the microcontroller( PIC16f690) is equiped with ECCP.

following code does not work.
//////////////////////////////////////////////////
set_tris_c(0x00);
setup_timer_2(T2_DIV_BY_16,253,1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(5000;
while(1);
////////////////////////////////////////////////
vinu
Guest







Error in previous post-ECCP
PostPosted: Thu Sep 14, 2006 5:44 am     Reply with quote

Dear Sir,

Anyone give an example for using ordinary PWM (single output from p1A ) when the microcontroller( PIC16f690) is equiped with ECCP.

following code does not work.
//////////////////////////////////////////////////
long value;
value=500;

set_tris_c(0x00);
setup_timer_2(T2_DIV_BY_16,253,1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(value);
while(1);
////////////////////////////////////////////////
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 14, 2006 11:45 am     Reply with quote

Post your compiler version. This will be a 4-digit number such as
3.191, 3.249, etc. You can find it at the top of the .LST file which
will be in your project directory.
vinu
Guest







PostPosted: Thu Sep 14, 2006 10:13 pm     Reply with quote

version number-- 3.225

regards,
vinu
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 14, 2006 11:46 pm     Reply with quote

Quote:
version number-- 3.225

The setup_ccp1() function is buggy for the 16F690 with your verison
of the compiler. To fix this, I've created a substitute function called
my_setup_ccp1(), as shown below. The code in it is a duplicate of
the code used by vs. 3.249 of the compiler, so it should work.

Try the following test program:
Code:

#include <16F690.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock=4000000)

#byte PORTC   = 0x07
#byte TRISC   = 0x87
#byte PIR1    = 0x0C
#byte T2CON   = 0x12
#byte CCP1CON = 0x17
#byte PWM1CON = 0x1C
#byte ECCPAS  = 0x1D

#bit CCP1_TRIS = TRISC.5
#bit CCP1_PIN  = PORTC.5

#bit TMR2ON    = T2CON.2
#bit TMR2IF    = PIR1.1

#inline
void my_setup_ccp1(int8 CCP1_value)
{
CCP1_TRIS = 1;
CCP1CON = CCP1_value; 
PWM1CON = 0;
ECCPAS  = 0;

if(TMR2ON)
  {
   TMR2IF = 0;
   while(!TMR2IF);   
  }

CCP1_TRIS = 0;
CCP1_PIN  = 0;
}
   
//====================================
void main()
{
long value;
value=500;

setup_timer_2(T2_DIV_BY_16, 253, 1);
my_setup_ccp1(CCP_PWM);
set_pwm1_duty(value);
     
while(1);     
}     
vinu
Guest







PostPosted: Sat Sep 16, 2006 2:07 am     Reply with quote

Thanks a lot. Finally the PWM is working. cost

Regards,
Vinu
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group