View previous topic :: View next topic |
Author |
Message |
drkome
Joined: 26 Dec 2024 Posts: 10
|
HS ADC Interrupt problem. |
Posted: Fri Mar 21, 2025 5:29 am |
|
|
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
|
|
Posted: Fri Mar 21, 2025 6:24 am |
|
|
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
|
HS ADC Interrupt problem. |
Posted: Fri Mar 21, 2025 6:41 am |
|
|
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);
}
}
|
|
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19755
|
|
Posted: Fri Mar 21, 2025 8:09 am |
|
|
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
|
HS ADC Interrupt problem. |
Posted: Sun Mar 23, 2025 3:36 am |
|
|
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. |
|
 |
|