View previous topic :: View next topic |
Author |
Message |
adcor
Joined: 21 Feb 2008 Posts: 31
|
[Solved] dsPIC33CH512MP505 and ADC issue |
Posted: Wed Jun 02, 2021 12:17 am |
|
|
I am trying to read a simple ADC value but it does not work. The loop stops after trying to to read_adc(), no printouts. Am I missing something? compiler v5.103
thanks
Code: | #include <33CH512MP505.h>
#device ICSP=1
#device ADC=10
#DEVICE CONST=READ_ONLY
#FUSES FRC_PLL
#FUSES NOWDT //No Watch Dog Timer,
#FUSES ALTI2C1 //use alternate I2C1
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES S1_CKSFSM //Slave core Clock Switching is enabled, fail Safe clock monitor is enabled
#use delay(internal=180000000)
#pin_select U1TX=PIN_C13
#pin_select U1RX=PIN_C12
#use rs232(UART1,baud=115200,stream=DEBUG,ERRORS)
void main()
{
char i;
unsigned int16 adc1,adc2;
setup_adc_ports(sAN0|sAN1);
setup_adc(ADC_CLOCK_FOSC | ADC_CLOCK_DIV_4 | ADC_WARMTIME_16 );
while (1) {
printf("start_adc\n\r");
set_adc_channel(0);
delay_us(10);
printf("test1\n\r");
adc1=read_adc();
printf("adc1=%Lu\n\r", adc1);
delay_ms(1000);}
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Wed Jun 02, 2021 3:17 am |
|
|
Try setting the option ADC_ENABLE_SHARED_CORE.
I remember having problems with another version of this chip a while ago.
The core available to the master chip is a 'shared core', so needs the shared
core options setup. SHARED_CLOCK, and TAD_MUL. Some of the chips also
had issues unless TAD_MUL was set above about 2. |
|
|
adcor
Joined: 21 Feb 2008 Posts: 31
|
SOLVED - dsPIC33CH512MP505 and ADC issue |
Posted: Wed Jun 02, 2021 4:18 am |
|
|
Yes it did the trick. Thank you! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Wed Jun 02, 2021 6:19 am |
|
|
That is pleasing.
Dragged from my memory of about a year ago, playing with one of the first
of those chips!...
I went through the data sheet, and realised the master core was always
'shared'. |
|
|
|