EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

A/D Special event trigger

Started by kalyanramu vemishetty November 16, 2004
Hi all,
In PIC18f452/ PIC16f877, there is "Special Event Trigger " for A/D conversion.
Did anybody ever use this special event trigger.
I am using PIC-C and working with special event trigger. But so far I didn't have success with it. I couldn't make it work with interrupts.
Does anyone has any suggestions or sample code or links.
I would be thankful if anyone can help me.
Thanks,
Kalyan




--- In , kalyanramu vemishetty
<kalyanramuv@y...> wrote:
> Hi all,
> In PIC18f452/ PIC16f877, there is "Special Event Trigger " for A/D
conversion.
> Did anybody ever use this special event trigger.
> I am using PIC-C and working with special event trigger. But so far
I didn't have success with it. I couldn't make it work with
interrupts.
> Does anyone has any suggestions or sample code or links.
> I would be thankful if anyone can help me.
> Thanks,
> Kalyan


Hi Kalyan, I've used the S.E.T. with the CCP1 module and polled I/O
on the CCP1IF flag, to produce a constant period timer, but not with
CCP2 + A/D conversion, or interrupt, initiation.

My usual procedure with PIC peripherals is to first get them to work
using polled I/O, and once that's verified, then integrate then into
the interrupt service routine. IOW, set up and verify one thing at a
time, and then put them together. You have to have all the peripheral-
config registers programmed correctly, the timer periods set, and the
enable flags all set properly, before things will work together, so
it helps to verify the setups separately. - dan michaels
www.oricomtech.com
========================




It runs in my mind that the conversion itself is pretty quick, it's
the acquisition time (charging the cap) that is longer. iirc,
conversion was on the order of low 10s of clocks at 20mhz.

I had worked out a scheme where I would:
- start acquisition and start a timer for the acquisition time
- at timer interrupt I'd start the conversion
- at conversion complete interrupt I save the
value and start the next acquisition going (and timer)

It worked but turned out to be more complex than I liked (2 different
ISRs) so I just ran everything off a regular timer tick to do the
conversion, wait for completion, save results and start the next
acquisition. Simpler code, easier to debug and less interrupt
overhead (since I was running the timer for other purposes already).
I'm sure my first method would allow a higher rate of ADC but I didn't
need it. --- In , "dan michaels" <dan@o...> wrote:
>
> --- In , kalyanramu vemishetty
> <kalyanramuv@y...> wrote:
> > Hi all,
> > In PIC18f452/ PIC16f877, there is "Special Event Trigger " for A/D
> conversion.
> > Did anybody ever use this special event trigger.
> > I am using PIC-C and working with special event trigger. But so far
> I didn't have success with it. I couldn't make it work with
> interrupts.
> > Does anyone has any suggestions or sample code or links.
> > I would be thankful if anyone can help me.
> > Thanks,
> > Kalyan > Hi Kalyan, I've used the S.E.T. with the CCP1 module and polled I/O
> on the CCP1IF flag, to produce a constant period timer, but not with
> CCP2 + A/D conversion, or interrupt, initiation.
>
> My usual procedure with PIC peripherals is to first get them to work
> using polled I/O, and once that's verified, then integrate then into
> the interrupt service routine. IOW, set up and verify one thing at a
> time, and then put them together. You have to have all the peripheral-
> config registers programmed correctly, the timer periods set, and the
> enable flags all set properly, before things will work together, so
> it helps to verify the setups separately. > - dan michaels
> www.oricomtech.com
> ========================




The 2024 Embedded Online Conference