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

HS ADC Interrupt problem.

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



Joined: 26 Dec 2024
Posts: 10

View user's profile Send private message

HS ADC Interrupt problem.
PostPosted: Fri Mar 21, 2025 5:29 am     Reply with quote

Hello, I want to adc read from adc interrupt.


Code:

void OPAMP_Init(){

         ADCON1  = 0x03E0;
         ADCON2  = 0x0104;
         ADCON3  = 0x0004;
         ADCHS   = 0x0023;
         ADCSSL  = 0x0000;
         ADPCFG  = 0xFFFF;
         IFS0    = IFS0 & 0xF7FF;
         IEC0    = IEC0 | 0x0800;
         ADCON1 = ADCON1 | 0x8000;
}

#int_ADC1
void adc1_isr(void) {

     currentOpamp.a = ADCBUF0; // AN0 sonucu
     currentOpamp.b = ADCBUF1; // AN1 sonucu
     currentOpamp.c = ADCBUF2; // AN2 sonucu
     
     output_d(0b1100);

     IFS0 = IFS0 & 0xF7FF ;  //kesmyi s�f�rla
   
}


Did I do something wrong? I want to program one that normally works with pwm synchronization for FOC control. But I wrote something like this for the beginning. There are many for mplab on the internet, but I want to do it in ccs c. Interrupt does not jump. I even wrote output_d command to turn on the led. Thank you for your answers.
temtronic



Joined: 01 Jul 2010
Posts: 9442
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 21, 2025 6:24 am     Reply with quote

quik comments...
you need to post which PIC you're using,
as well as compiler version
and of course the main() program. well the beginning , to see IF you've enabled the ADC interrupt.
drkome



Joined: 26 Dec 2024
Posts: 10

View user's profile Send private message

HS ADC Interrupt problem.
PostPosted: Fri Mar 21, 2025 6:41 am     Reply with quote

ahh sorry I forgot to say them. I am using dsPIC30F4011. Complier version V5.113.

Code:


 void main(){

 
  OPAMP_Init();
 
  while (1) {
 
      fprintf(RS232,"DEGER1 = %d \n\r" ,currentOpamp.a);
      fprintf(RS232,"DEGER2 = %d \n\r" ,currentOpamp.b);
      fprintf(RS232,"DEGER3 = %d \n\r" ,currentOpamp.c);

  }


}


Code:
Ttelmah



Joined: 11 Mar 2010
Posts: 19755

View user's profile Send private message

PostPosted: Fri Mar 21, 2025 8:09 am     Reply with quote

You have not got the ASAM bit on, so the chip won't start sampling on it's
own. You then don't set SAMP, so no sampling will actually start. The
synchronise bit to the PWM, stope sampling when this trigger is seen and
then performs the conversion, but something has to actually start the
sampling first for this to happen. You are not setting anything to do this.....

Also in what you post, there is no sign of the interrupt being enabled, or the
global enable being set, so no interrupt would happen.
drkome



Joined: 26 Dec 2024
Posts: 10

View user's profile Send private message

HS ADC Interrupt problem.
PostPosted: Sun Mar 23, 2025 3:36 am     Reply with quote

Ah okay I will try this tomorrow. I need to read lowside current from adc with interrupt for FOC control for BLDC. Thanks for answering.
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