This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Question about PEC

Hi again,

I am using C167. I am using PEC for AD-conversion.
I configure PEC as follows:
ADCIC = 0x007B;
PECC3 = 0x00FF;
SRCP3 = (int) (&ADDAT);
DSTP3 = (int) (&P3);
ADCON = 0x0090;
I works fine to transfer values to from ADDAT to port P3. . Now I want to determine how many times AD-conversion has taken place.

In PECCx there are 8-LSB are:
COUNT (PEC Transfer Count)

Now I wonder if I am on right track or there are other way to do what I want.
Even if I use the 8-LSB of PECCx I can have the max value 2 raised to power 8 i.e. 256,
what happens if the nr of AD-conversion exceed 256?

Can someone help me in this regard?
Send me mail if something is not clear.
thanks in advance
regards
/M

Parents
  • Dear Mohammad,
    this sounds like a totally new approach.
    Your code looks like you are polling the ADC Result register. Therefore you do not need the PEC transfer mechanism.
    But between starting and reading the ADC you must wait the ADC conversion time. Check the busy flag of the ADC (ADBSY). If ready then read ADDAT and accumulate the values as described.
    BTW your code accumulate 101 ADC values.
    regards
    Uwe

Reply
  • Dear Mohammad,
    this sounds like a totally new approach.
    Your code looks like you are polling the ADC Result register. Therefore you do not need the PEC transfer mechanism.
    But between starting and reading the ADC you must wait the ADC conversion time. Check the busy flag of the ADC (ADBSY). If ready then read ADDAT and accumulate the values as described.
    BTW your code accumulate 101 ADC values.
    regards
    Uwe

Children
No data