| View previous topic :: View next topic |
| Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 20062
|
|
Posted: Wed Feb 25, 2015 10:14 am |
|
|
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
|
|
Posted: Wed Feb 25, 2015 2:22 pm |
|
|
| 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: 20062
|
|
Posted: Wed Feb 25, 2015 3:04 pm |
|
|
| 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
|
|
Posted: Mon Mar 02, 2015 5:34 pm |
|
|
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 |
|
 |
|