View previous topic :: View next topic |
Author |
Message |
masaldzhiyski
Joined: 03 Sep 2012 Posts: 1
|
PIC24F, PROTEUS SIM |
Posted: Mon Sep 03, 2012 1:25 pm |
|
|
Hi, I'm new to PIC24 and I'm having difficulties on using the ADC with it. My simulator ISIS Proteus gives me a warning that looks like "ADC conversion clock period [31.25n] is below minimum recommended [75]n]."
I am posting my code hoping to find clear answers on why is this warning occurring and how can I approach this issue. Thanks in advance.
Code: |
#include <24fj128ga010.h>
#fuses XT, NOWDT, NOPROTECT
#DEVICE ADC=10
#use delay(oscillator=8M,clock=32M)
int16 PORTB;
#byte PORTB=0x2c8
int16 PORTD;
#byte PORTD=0x2d4
int16 PORTE;
#byte PORTE=0x2da
int16 PORTG;
#byte PORTG=0x2e6
#bit VCFG_BIT = 0x0322.13
#define ALL_OUT 0
#define ALL_IN 0xff
#include <math.h>
#include <float.h>
#include <stdlib.h>
void main()
{
int i=0;
int k=0;
int pause;
int arraySINE[1024];
int arraySINE2[1024];
int arraySINE3[1024];
int fin_val=0;
float32 value=0;
setup_adc(ADC_CLOCK_DIV_128|ADC_TAD_MUL_4);
setup_adc_ports(sAN11|VSS_VREF);
VCFG_BIT = 1;
set_tris_b(0xfc00);
set_tris_d(ALL_OUT);
set_tris_e(ALL_OUT);
for(i=0;i<=1023;i++)
{
value=sin(k*0.351563*0.017453)*511+511;
fin_val=(int)value;
arraySINE[i]=fin_val;
k=k+1;
}
k=120;
for(i=0;i<=1023;i++)
{
value=sin(k*0.351563*0.017453)*511+511;
fin_val=(int)value;
arraySINE2[i]=fin_val;
k=k+1;
}
k=240;
for(i=0;i<=1023;i++)
{
value=sin(k*0.351563*0.017453)*511+511;
fin_val=(int)value;
arraySINE3[i]=fin_val;
k=k+1;
}
do {
for(i=0;i<=1023;i++)
{
PORTD=arraySINE[i];
PORTE=arraySINE2[i];
PORTB=arraySINE3[i];
set_adc_channel( 11 );
delay_us(10);
pause=read_adc();
delay_us(pause);
}
} while(1);
}
|
It is a program that creates 3phase sine waves with r2r ladders on each port. Speed is of essence here. The actual program will be implemented on a PIC24HJ using its 80MHz clock . I would appreciate if someone could give me tips about the configuration of the 80MHz clock and some help on the ADC issue. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Mon Sep 03, 2012 1:31 pm |
|
|
Start by reading the sticky at the top of the forum.
Seriously, Proteus as a PIC simulator, is full of bugs. It'll accept things that'll never work, but reject things that are fine.
Go elsewhere for questions about this. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Sep 03, 2012 1:33 pm |
|
|
ahhhh...... you beat me to it! _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
|