Quantcast
Channel: Processors
Viewing all articles
Browse latest Browse all 123958

Forum Post: RE: GPIO sampling rate on C6670

$
0
0

Hi Hardik,

The GPIO module is considered a low speed module and was never intended for data sampling. You have made a couple of bad assumptions in you analysis.

First, the 12C input timing requirement defines the minimum width pulse that the GPIO module can reliably sample. Note that the GPIO module samples this pulse independent of the processor.  If the pulse is a shorter duration than 12C, the GPIO module may not sample it. Usually this minimum is used to define the shortest interrupt pulse that may be used by the GPIO. This does not define how fast the GPIO pin can be read by the processor. The delays within the part and the delays added by the software can be significant. 

Secondly, you are using the GPIO to generate the clock and to sample the data. That means you would have to write to your clock GPIO pin to set it low and then write again to set it high followed by a read of the data pin. That is three separate accesses to the GPIO module. The GPIO module is clocked at the slow peripheral clock rate of SYSCLK1/6. The minimum output pulse is 36C-8 or approximately 30ns for your core clock rate. Even if the device was able to execute two writes followed by a read without any other delays, (which it can't) you would need 72ns per data bit.  

Finally, it looks like you are using GPIO functions to do your reads and writes. Function calls will add significant delays due to the overhead associated with saving the context before executing the function and restoring the context after it's complete. You may be able to speed up your accesses by writing your own function to sample all of the bits. It would have to operate in a manner similar to the following.

Write OUT_DATA register to set clock bit low

Write OUT_DATA register to set clock bit high

Read IN_DATA register to get data bit value to a temporary register

Mask off the data bit in the temporary register.

Shift it to bit location 0

Shift your result register one bit to the left

OR the results register with the temporary register

Repeat these statements thirteen more times. 

Note that all reads and writes would have to be direct read and write statements and not GPIO function calls. Also note that using a FOR loop or a WHILE loop would add more overhead. Simply repeat the statements fourteen times to read all the bits. This may speed things up but I doubt you will reduce the time much.

Regards, Bill


Viewing all articles
Browse latest Browse all 123958

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>