View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
I can't turn on the ADC of 30F5015 |
Posted: Thu May 23, 2013 2:57 am |
|
|
Hi! I can't take any reading from the ADC modul of 30F5015. Here is my program:
Code: |
#include <30F5015.h>
#device ADC=12
#FUSES HS2_PLL8,NOWDT
#use delay(clock=80M)
void main()
{
setup_adc_ports( sAN0 );
setup_adc(ADC_CLOCK);
set_adc_channel( 0 );
int value=0;
while(1)
{
value=read_adc();
delay_ms(100);
}
}
|
I have around 2.5V on PIN B0(AN0) and PIN B1(AN1).
When I turn on the program it's running but always value=0. I tried with ADC_CLOCK_INTERNAL - no change.
What am I missing?
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu May 23, 2013 7:51 am |
|
|
ADC_CLOCK, requires you to feed in an external clock for the ADC.....
ADC_CLOCK_INTERNAL should work though.
Questions:
1) What compiler version?.
2) How are you running this?.
There is no printout, so it suggests a debugger. Not all debuggers can simulate the ADC.
Best Wishes |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Thu May 23, 2013 8:22 am |
|
|
I`m using v4.134. It`s not a simulation. I have a pcb with 30F5015. I have 20MHz quartz. The controller is running correctly - I`m generating PWM signals with it. I`m using Pic Kit 3 as debugger and I`m watching the value variable int the watch window.
Best regards! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu May 23, 2013 9:08 am |
|
|
There are _several_ 'limitations' in the release notes for the PicKit3, regarding certain PIC30's, and the ADC.
Try the code for real. Setup a serial output, print the value to this, and see what happens without the debugger.
Best Wishes |
|
|
|