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

Help with clocking code
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Wed Feb 25, 2015 10:14 am     Reply with quote

You have already solved that:

ADC_CLOCK_DIV_64

That gives Tad = 1.33uSec

ADC_CLOCK_DIV_32, takes the Tad to 0.66uSec, so is too fast at 48MHz.

If you want to include the TAD_MUL delay, the specified acquire time is 6.4uSec if the source is 2.5KR. So TAD_MUL_6 would be the lowest value that could be used (4 would be a little too short).
younder



Joined: 24 Jan 2013
Posts: 53
Location: Brazil

View user's profile Send private message

PostPosted: Wed Feb 25, 2015 2:22 pm     Reply with quote

Ttelmah wrote:

If you want to include the TAD_MUL delay, the specified acquire time is 6.4uSec if the source is 2.5KR. So TAD_MUL_6 would be the lowest value that could be used (4 would be a little too short).


Where did you get the 6.4uSec with source = 2.5KR? EQUATION 21-3: shows a minimum of 2.45uSec of acquisition time with source = 2.5KR... am I missing something?
_________________
Hugo Silva
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Wed Feb 25, 2015 3:04 pm     Reply with quote

I'm using figures I was given by Microchip after I had problems with the ADC. The multiplexer internal resistance is higher than specified. However this may only apply to the early revision I was using at the time, since they have not documented it on the release chips.
younder



Joined: 24 Jan 2013
Posts: 53
Location: Brazil

View user's profile Send private message

PostPosted: Mon Mar 02, 2015 5:34 pm     Reply with quote

A few changes in the code... and it's working just fine... Thanks Ttelmah!

Code:

union pulse_data_type { 
   int8 buffer;
   struct {
      int1 _50;
      int1 _100;
      int1 _200;
      int1 _500;
      int1 _1000;
   } mSec;
};
 union pulse_data_type pulse=0;
#INT_TIMER1
void timer1()           
{
  static int8 counter_SP[5] = {2,4,8,20,40}; //Counters Setpoint (Value*25ms)
  static int8 i, counter[5] = {2,3,4,5,6}, mask;
 
  set_timer1(28035 + get_timer1()); //35000 counts = 25mSec
  mask=1;
  for (i=0;i<5;i++)
  {
      counter[i]--;
     if (counter[i]==0)
     {
        counter[i]=counter_SP[i];
        pulse.buffer^=mask;
     }
     mask*=2;
  }
}


Any suggestion on the Edge code? I tried to set the flag inside the ISR, since I know when the pulse is changing the state... but I had a hard time trying to figure out when and where to reset it...
_________________
Hugo Silva
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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