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

fix mystery glitches in CCS NCO functions for 16f1509

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

fix mystery glitches in CCS NCO functions for 16f1509
PostPosted: Fri Jul 11, 2014 9:25 am     Reply with quote

I found that when jamming new frequencies into the NCO using the CCS function that there was frequent glitching of my pulse train.
This is a function that appears to correct the problem.
( NCO used for stepper motor pacing - and the problem
could be HEARD before it was seen )

Code:

void setNCOfreq(unsigned int16 pfreq){
    // bank nine page 31 of data sheet
    STATIC int Psetupok;
    #WORD ncoinc=0x49B

  // detect  STOP CMD
  if (!PFreq) {
       setup_nco(NCO_DISABLED|NCO_FIXED_DUTY_MODE|NCO_CLOCK_FOSC,0);
       Psetupok=0;
  }
  else {
      if(0==psetupok){
    setup_nco(NCO_ENABLED|NCO_OUTPUT|NCO_FIXED_DUTY_MODE|NCO_CLOCK_FOSC,pfreq);
        Psetupok=1;
      } // avoid glitches induced when NCO is already generating
      else ncoinc=pfreq;
  }
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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