MOD5234 ETPU IC Function Lesson Learned

Discussion to talk about software related topics only.
Post Reply
joepasquariello
Posts: 85
Joined: Mon Apr 28, 2008 7:32 am

MOD5234 ETPU IC Function Lesson Learned

Post by joepasquariello »

For anyone using the ETPU IC function with interrupts on MOD5234, make note of this issue. The IC init function has a parameter called MaxCount, which is the number of edges after which the function will capture a timestamp and generate an interrupt. It also has an internal variable called TransCount, which is the count of transitions. The documentation implies that if you wanted an interrupt every 10 rising edges, you would get an interrupt on edge 10, 20, 30, etc. That's the ITC and NITC function work on the older TPU, TPU2, and TPU3, but not on the eTPU, at least for Coldfire. If you set MaxCount to N, you get an interrupt on each N, N+1, N+2, etc. In our case, N was 1, so we were getting an interrupt on every edge, which was correct.

The reason the function works the way it does is that when an edge occurs, TransCount is incremented and an interrupt is generated if TransCount >= MaxCount. That's true after MaxCount edges and for every edge after that. However, when TransCount reaches 0x800000, the condition is false because TransCount is defined as a SIGNED 24-bit integer, and 0x800000 is negative, so no interrupt occurs. Once TransCount >= MaxCount, an interrupt occurs on every edge until TransCount reaches 0x800000, then no interrupts occur until TransCount reaches 0xFFFFFF and rolls over to 0. In our case, this was hours.

I reviewed the documentation for the TPU's ITC and NITC functions, and they both set TransCount=0 after MaxCount edges. So, I would call this a bug in the IC function. It sure seems like one.

There are some work-arounds if you want to use IC with interrupts:

1) In your ISR, set TransCount=0 via fs_etpu_ic_set_trans_count() to get an interrupt every MaxCount edges.
2) If what you want is an interrupt every edge, set MaxCount=0x800000, so TransCount>=MaxCount is always true.
3) Use the PPA function, which also has a MaxCount parameter, but generates an interrupt every N edges as expected.

Here is an NXP forum thread from 2008 on this topic.

https://community.nxp.com/thread/43100

Joe
Post Reply