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 support@ccsinfo.com

PWM issues on 16F883

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



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PWM issues on 16F883
PostPosted: Mon May 30, 2011 12:53 pm     Reply with quote

Hi There,

I'm using PWM 1 & 2 on a PIC16F883 with 200kHz.
It seems to work somewhat but every 40ms I get a 40ms break where I don't have a pwm available on PIN_C2. So it's like as if a frequency (~11.74Hz) was overlayed on top of my pwm. Why is that?

Thank you for hints & suggestions!


See my sample app:
Code:

#include <16F883.h>
#case
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=20000000)

void main(void) {

setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);   
setup_timer_2( T2_DIV_BY_1, 24, 1);
set_pwm1_duty(13);
set_pwm2_duty(13);

while(1);

}   
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

[SOLVED] PWM issues on 16F883
PostPosted: Mon May 30, 2011 2:54 pm     Reply with quote

Uh, I was told that it just appears like this on the oscilloscope because of FFT with our Tektronix - I'll need to do some research on that to get refreshed....
Ttelmah



Joined: 11 Mar 2010
Posts: 19364

View user's profile Send private message

PostPosted: Mon May 30, 2011 3:05 pm     Reply with quote

No reason at all with the code as given....
Check with something not using the PWM. Just sit the code in a loop toggling this pin. Does this then work OK, or is the problem still there?. If the latter, you need to be looking at a hardware source. Something silly like noise on MCLR?.
What compiler version?.
Code:

#include <16F883.h>
#case
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(clock=20000000)

void main(void) {

   //setup_ccp1(CCP_PWM);
   //setup_ccp2(CCP_PWM);   
   //setup_timer_2( T2_DIV_BY_1, 24, 1);
   //set_pwm1_duty(13);
   //set_pwm2_duty(13);

   while(1) {
      output_toggle(PIN_C2);
      output_toggle(PIN_C1);
   }
}   


Won't be 200K, but won't be that far off!...

Best Wishes
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Mon May 30, 2011 3:52 pm     Reply with quote

Well I couldn't do that in my real app, as said, this is just a little sample program to demonstrate the problem i'm experiencing. But as we've already figured out here, it's the Fast Fourier Transform of my Tektronix scope that gets "confused" - this error is not actually physically on my pic nor on the board.
Ttelmah



Joined: 11 Mar 2010
Posts: 19364

View user's profile Send private message

PostPosted: Tue May 31, 2011 1:56 am     Reply with quote

I posted before your reply appeared.
Old lesson 'know your tools'. Weird, have never seen anything like that on my Tektronix scopes, but presumably an oddity of your particular unit.

Best Wishes
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Tue May 31, 2011 9:41 am     Reply with quote

Ttelmah wrote:
I posted before your reply appeared.
Old lesson 'know your tools'.

Yep, I fully agree!
Ttelmah wrote:
Weird, have never seen anything like that on my Tektronix scopes, but presumably an oddity of your particular unit.

No, it could happen on any digital oscilloscope as far as i know, it's just a matter of how the FFT is imoplemented. My device is the TDS 3012B dual channel scope.
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