Author Topic: iic problem  (Read 9550 times)

Offline kaflick

  • Newbie
  • *
  • Posts: 20
    • View Profile
iic problem
« on: April 13, 2012, 01:21:00 AM »
I have a problem with the iic routine.  I changed my application from running on a 1ms
timer (which seemed very irregular) to being called every 1ms in TaskConfig.h (which
seems very regular) and everything works fine except the iic which waits forever in the
new lines labeled 116 in fnTxIIC (specifically on the while).  It never comes out.

I made sure it was being set up by getting through fnConfigIIC and it looked OK.

What should I look at?

Keith Flick

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3237
    • View Profile
    • uTasker
Re: iic problem
« Reply #1 on: April 13, 2012, 02:05:16 AM »
Hi Keith

This is waiting on the busy flag. This was added in 2009 becasue it was found that the transmission of following messages could start when the stop condition was still in progress, whcih caused problems. It should wait only for about a bit period at maximum.

Can you see whether the bus is in a valid state? Are the pull-up resistors correctly attached, for example. If it is doing this on a first message I expect that I2C controller believes that the bus is in use.

Regards

Mark

Offline kaflick

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: iic problem
« Reply #2 on: April 13, 2012, 02:51:59 PM »
I have the iic running, it works fine.  It is being called a from a 1ms timer.

When I change the app to be called at a 1 ms period from TaskConfig.h
and move my call to :

     fnWrite(IICPortID, (unsigned char *)&(output_i2c.data.address), sizeof (comStruct));

from the 1MS timer routine (which I don't have any more) to the base fnApplication
routine it hangs on the first call.  That is the only change between the two versions of
code.

Is there a problem with changing the base fnApplication routine called every 1ms, does it
need to be called more often?  (I just modified your fnApplication routine to add my code.)

What else should I look at?


Offline kaflick

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: iic problem
« Reply #3 on: April 13, 2012, 03:01:01 PM »
I moved the call to write to the iic from before the while
that processes the input queue to the very end of fnApplication
and now it runs for a while (20 or 30 ms) and then gets an
undefined interrupt so I''ll take a look at what is happening and get back
to you if I continue to have a problem.

Thank you
Keith Flick

Offline kaflick

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: iic problem
« Reply #4 on: April 13, 2012, 06:03:24 PM »
I have now restored the fnApplication to it's normal configuration in
TaskConfig.h.  I have added a control task that gets called every 1 ms
that does our control and communication over iic.

The first time the write to iic is called it hangs on the while in the
116 code.  When I go to the registers to see what is happening I
cannot read anything at addresses in the 0x40000300 range (I get
all ***** in codewarrior).  This looks like it is not initialized
correctly.

I have followed it through the init routine and it seems OK, for instance
it is calling the powerup so I would expect to be able to read those addresses.
 any suggestions on what to look at next?

Keith Flick

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3237
    • View Profile
    • uTasker
Re: iic problem
« Reply #5 on: April 16, 2012, 10:40:44 PM »
Hi Keith

At the moment I really can't imagine what the problem is.

It is true that accessing registers of peripherals that haven't been powered up will result in an access error (and do display in the debugger) so I would suggest when you are in this state you check the state of PPMRH and PPMRL to see whether the module is powered or not - if it's control bit is not as expected you can also set it manually to verify that the registers can be read correctly.

In the case that the module is being powered down and up (for some reason) it may also explain other strange effects.

Regards

Mark