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

PEC problem

I have recently changed my interrupt routines to use the 'using RB_LEVELx' format. This seems to have caused a problem which crashes the I2C module. I have tracked the source to a line of code executed in the EOP interrupt routine. I use the ADC with PEC and at the end of each full conversion cycle the PEC control register needs to be reloaded for the next cycle. Its that line of code which seems to crash the I2C module!

As i say this only became apparent after all interrupts where modified to use reg banks. If i comment out the PEC reload code the problem is solved!

Has anyone had any experience with PEC problems or anything that may help.

  • Once, I ported a project from Tasking to Keil, register banks were used so I kept using them in the Keil project. There were several interrupts all using their own register bank. Sporadic crashes would ensue, I don't remember all the details but I came to the conclusion that it had something to do with mixing up PEC and reg banking.

    I noticed that if I removed, say exactly 2 register banks, no matter in which interrupt, then the problem would go away.

    Being not very familiar with register banks, I just proved that register banking was not necessary, removed all of them, and that "solved" the problem.

    Let us know if you find the root cause of your problem!

    -Stephane

  • Hi, i wouldnt say i quite found the root of the problem but i increased the I2C data interrupt to 1 higher than the ADC interrupt and that stopped it crashing.

    Also if i removed all the 'using REGBANKx' from all interrupts that helped too.

    Its all very strange, if anyone else has had problems using reg banks please let us know.

    Thanks,

  • if you have correctly implemented IIC (NOTE: not SMbus, which otherwise is identical) the IIC will wait for years if required.

    Erik

  • if you have correctly implemented IIC

    The code for I2C was generated by DaVE Code genterator V2.8 and worked fine before using regbanks. But it is the actual module of the XC161 that stops responding, not the code.

    If anyone has any better I2C routines / library for the XC161 please let me know if they would share them.