Thank you for your help and patience !
Thank you for your help and patience !
Can somebody help me with this code for 12F683: ?
I want to blink very quikly a led in background ,independent of my code, random, pause between 1-20 ms. I think that this interval is ok, the best if its possible to set pause limits.
I want learn about intrerupts but i think that I'm too old ...
thx in advance !!
...or , how I can make SPWM without intrerupts...?
Darrel came up with a terrific piece of code for my project - have a look at this thread:
http://www.picbasic.co.uk/forum/showthread.php?t=17299
Hi,
I guess you COULD use ADCIN but it kind of defeats the purpose of the interrupt since it is a self timed command.
When using ADC interrupts you basically set the GO/DONE bit to start the converstion and the interrupt fires when the ADC conversion is done. If you then use ADCIN in the interrupt handler it would perform another, self-timed, conversion which, again, kind of defeats the use of interrupts in the first place.
The idea is to start the conversion and then either go to sleep or go do something important while the ADC does its job. The interrupt fires when the conversion is complete and you go grab the result by reading ADRESH/ADRESL register pair.
/Henrik.
Thanks Henrik. I've never done A/D conversion before other than through ADCIN but I guessed it wouldn't make sense to use in an interrupt. I'll have to do a search on 'ADRESH' to see how to read the result when I turn the trim pot dial.
I've set up and ADC interrupt using DT_INST-14 with the following handler code:
Is that right? I just need 8-bit ADC resolution (0-255)Code:' *************************************************************** ' [A/D - interrupt handler] ' *************************************************************** ADC_change: PAUSEUS 50 ' Wait for A/D channel acquisition time ADCON0.1 = 1 ' Start conversion WHILE ADCON0.1 ' Wait for it to complete WEND ADCInVal = ADRESH @ INT_RETURN
Try this as an intro to Darrel Interrupts and blinking LED:
http://darreltaylor.com/DT_INTS-14/blinky.html
It's worth the time to practice. His routines make things so much easier and flexible later on as you add more complexity to your code.
Robert
Bookmarks