EEprom and MCP9801 I2C communication problems


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Apr 2011
    Location
    NSW, Australia
    Posts
    39


    Did you find this post helpful? Yes | No

    Default Re: EEprom and MCP9801 I2C communication problems

    Well,

    This project has developed a bit from the early start.

    The initial bit was a learning curve on communications. The project itself was to create a 3 phase sinewave to drive a reactive power compensation board.

    I changed from I2C to SPI and use 3 DACs to output the 3 phases shifted by 120 degrees.

    Photos to follow. I used a free PCB software to produce the board. If anyone is looking for a free package, PCB Artist is really good.

    Because I needed to have it switchable for 50 and 60 hz and to get the timing correct, I used a PAUSEUS command to get my delays. Is there any issues with that command? It seemed to work ok up to a couple of hundred uSecs, but after that the PIC would not run. I ended up putting in a for next loop and adjusting the number of times the loop executed to get the correct timing.

    Sorry cant post the code at the moment as its on my work computer.


    Thanks
    aajgss

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: EEprom and MCP9801 I2C communication problems

    There is nothing wroing with the PAUSEUS command, but if you using a variable after the PAUSEUS, it should be a WORD variable.

    Without looking at your code, there is no way of knowing what effect the longer delays may have.

    Anything that requires close timing should be done with a timer. Even if you aren't using interrupts, you can use a timer by setting up the prescaler and clock source, and turning the timer ON. When you want to start your timing interval, you clear the timer, and later on in the program you can sit in a loop until the timer is > a certain value. The upside is that you can do other tasks after you start the timer, and as long as the tasks don't take longer than your desired time interval, timing will be maintained. And this technique works especially well if you DO use interrupts, because the interrupts can "steal" time from the main loop, and make the PAUSEs take longer than their set value. Using a timer keeps timing perfect.

    The downside is that at 40MHz, TMR1 times out in ~52mSec even with a /8 prescaler.
    Charles Linquist

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: EEprom and MCP9801 I2C communication problems

    I guess I should have also added that TMR0 can have a lot longer time period because it has a /256 prescaler. I just always use TMR0 for my main interrupt timer and TMR1 for the time delays in the loop. You could reverse the operation and use TMR1 for ints and TMR0 for the loop timer. That will get you over 1 second.
    Charles Linquist

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts