Subject: Understanding port setup.
From: rotaryeng
Date: 8/14/2012, 2:16 PM
To: AAAA Put this in the To box


 One of the most difficult things to deal with is port set up on recent powerful CPU's.

 Chip makers are trying to accommodate as wide a range of hardware  applications as
 possible. Consequently even though a chip may have 100 pins each of those pins may
 have different functions. Input, output, capture, oscillator in, frequency out,
 analog input, PWM out and so on and so on.

 This is a nightmare for the hardware application engineers. Get it wrong and your
 hardware won't work.

 Switch registers are provided to set up the ports. There could be hundreds of switch
 registers.  Here is a list for the ARM. Two switch registers in series give four
 combinations. Some of the combinations may not make sense and become not allowed or
 do nothing. See my attached illustration.

 Three switches in series gives nine combinations! A real nightmare indeed.

 With every drawback there is a business opportunity. Somebody could set up a port
 configuration service where you can mail them a chip and they can set it up for your
 needs and mail it back. The switch registers being in flash memory don't forget.

 Something you could do in your home. Also possible is a program that generates the
 ASCii source code that sets up the ports. You tell it what you want the pin to do. A
 program that writes a program.

 Paul Lamar

Which chip has its peripheral selections in flash?

On Teensy, and every other chip I have used (and I have used many),
these settings are in hardware registers implemented as volatile
memory.  Virtually all chips boot up with the pins fully disabled or
configured as inputs by default, and then you write to the volatile
config registers during program initialization or on an as-needed basis.

I believe this was one of many topics we discussed over the phone,
during two lengthy calls.  At the time, I believe I suggested you should
gain some hands-on experience with the chip, and then we could speak of
these technical issues in detail.

Maybe you're using some other chip than the one on Teensy?  Seeing
"TRIS" in the diagram looks like something from Microchip.

Paul Stoffregen
http://www.pjrc.com


The diagram did come from a PIC. The AVR has port pin configuration like all other
CPU's. Way back in the early 6502 days the 6522 dual par. port chip required pin
configuration. I have gone beyond the AVR in the Teensy anyway even though I have one.

It matters not how or when the port configuration code gets in the memory.
The chip must have a program in there when it resets so the port configuration could
be just another include. You could offer to write and sell an include to suit your
customers pin configuration requirements. Also only certain pins can do A to D and
PWM. How many PWM pins are possible on the Teensy? How many A to D pins are possible
on the Teensy?

Paul Lamar



-- The Rotary Engine News Letter. Powered by Linux. ACRE NL web site. http://www.rotaryeng.net You Tube key word PaulLamar2 Copyright 1998-2012 All world wide rights reserved.