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

[Solved] dsPIC33CH512MP505 and ADC issue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
adcor



Joined: 21 Feb 2008
Posts: 31

View user's profile Send private message

[Solved] dsPIC33CH512MP505 and ADC issue
PostPosted: Wed Jun 02, 2021 12:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jun 02, 2021 3:17 am     Reply with quote

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

View user's profile Send private message

SOLVED - dsPIC33CH512MP505 and ADC issue
PostPosted: Wed Jun 02, 2021 4:18 am     Reply with quote

Yes it did the trick. Thank you!
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Wed Jun 02, 2021 6:19 am     Reply with quote

That is pleasing. Very Happy
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'.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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