Page 1 of 1

Simple question regarding GPIO on PK70

Posted: Fri Jun 25, 2010 6:42 am
by rsg
Q: Can I rely on the correctness of the file \Nburn\PK70\system\pins.cpp when it comes to which pins may be used as GPIO?

Details: I want to use some of the pins on the 40-pin connector as GPIO to implement a JTAG interface. Specifically, I would like to use TIN1, TIN2, DTOUT3, and IRQ7. Examining the GPIO chapter of the Freescale manual seems to imply that DTOUT3 is not available as a GPIO, and is unclear about IRQ7. However, the file pins.cpp in \Nburn\PK70\system clearly supports using all four pins as GPIO, which is obviously good news - if true. In there, registers from other parts of the processor are used. So it appears more of the 626 page Freescale manual needs to be understood, eh? ;)

So I'm just asking for confirmation that pins.cpp can be trusted in general, and specifically, that TIN1, TIN2, DTOUT3, and IRQ7 can indeed be used as GPIO. Granted, I will soon enough find out for myself one way or another as I write the code, but it would be helpful to remove a few of the unknowns (e.g. new software, new I/O code, custom hardware, etc.) before I begin!

Thanks!
-Bob

Re: Simple question regarding GPIO on PK70

Posted: Fri Jun 25, 2010 6:03 pm
by lgitlitz
The pins class works well and is tested on all of the GPIO pins on the PK70 40 pin header. I am not sure where in the Freescale manual implied that the DTOUT3 pin in not multiplexed to the GPIO peripheral but I am sure that it is. If you look at the very first page of the GPIO chapter in the reference manual there is a diagram that shows all the multiplexed GPIO pins. The timer port block shows all 8 dma timer inputs and outputs, they are PTIMER[0-7] as GPIO. The IRQ pins are actually not part of the GPIO controller but you can set them as output in the eport peripheral so they function exactly the same, just a different register set. Using the Pin class you will not know the difference.

I would say do all the initial coding using the pins class. It is much easier to read and debug then writing to the registers. Then once your JTAG is working you may want to rewrite this using the registers inline to your code instead of the pins class to get better performance. Most of the bit toggling you do only requires a single register write, 1 clock cycle. The pins class contains much more code and requires function calls so it will have a bit more latency.

One thing to look out for if you optimize the GPIO at using registers. There are 3 pins on the 40 pin header that are shared between two processor pins. Pin[25](SDA and U1RX), Pin[26](SCL and U1TX) and Pin[27](DTIN1 and U1RTS). Using the pins class will automatically take care of this. If you re-write this at the register level make sure to put the unused pin in GPIO as an input so it does not interfere with the other pin. You can see how this is done in pins.cpp.