Calling ADC in interrupt. Block All !

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
sygma22
Posts: 30
Joined: Tue May 27, 2008 1:47 pm
Location: FRANCE
Contact:

Calling ADC in interrupt. Block All !

Post by sygma22 » Wed Aug 06, 2008 10:50 am

Hello,

The program blocks completely when j' call: " Adc0 = ADC.Read (0) " in a routine d' interruption. But when I make l' call in the loop pricipale, any problem????????

for 18F4620 :

Clock = 20

(PR2 = 64) -----> Int callled all the 13 us
ADC.SetAcqTime(11)
ADC.SetConvTime(FOSC_4)

Interrupt RTC() ----> Here is Block All --> (OverSomethink ??????)

Adc0 = abs(ADC.Read(0))
delayus(50)
PIR1.1 = 0 ' clear interrupt flag
End Interrupt

While true ------> Here is OK
Adc0 = abs(ADC.Read(0))
wend
My first interest is working with a PWM signal.

Motor : 24 Volts 4 or 5 A.

User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Post by octal » Wed Aug 06, 2008 1:29 pm

Hello,

Read the Swordfish documentation (or Help file) concerning the Context saving/restoring in interrupt routines.

See http://www.sfcompiler.co.uk/downloads/SFManual.pdf (the pdf doc) Page 46 - Context Saving section.

Regards
octal

sygma22
Posts: 30
Joined: Tue May 27, 2008 1:47 pm
Location: FRANCE
Contact:

Thanks your !

Post by sygma22 » Wed Aug 06, 2008 1:52 pm

Hello, Thanks very much.

If i understand, it's force the Interrupt to Wait the include Sub....

Here Is The Simple Result :

Interrupt RTC() :)


save(0,ADC.Read)
Adc0 = ADC.Read(0)
restore

PIR1.1 = 0 ' clear interrupt flag
End Interrupt
My first interest is working with a PWM signal.

Motor : 24 Volts 4 or 5 A.

Post Reply