µTasker Forum

µTasker Forum => NXPTM M522XX, KINETIS and i.MX RT => Topic started by: frank on November 09, 2009, 07:22:38 PM

Title: GPIO Setting for PORTTA
Post by: frank on November 09, 2009, 07:22:38 PM
Hi,

If I want to use PORTTA for GPIO functionality ( in my case as an input ) is the following setting correct ?.

PTAPAR = 0;
DDRTA = 0x00; //input
unsigned char var = PORTIN_SETTA;

Do I need to do anything else ?.
Title: Re: GPIO Setting for PORTTA
Post by: mark on November 09, 2009, 09:08:44 PM
Hi Frank

PTAPAR is only needed if the port was previously configured as peripheral function.

Generally try to use the port macros (search for "port macros" in M5223x.h) since these will help keep code portable.
Also the port macros can be used as reference:

Eg. to set just bit 1 to input and read its vale you can use:
_CONFIG_PORT_INPUT(TA, 0x02);
unsigned char var = _READ_PORT_MASK(TA, 0x02);


or for the complete port:
_CONFIG_PORT_INPUT(TA, 0xff);
unsigned char var = _READ_PORT(TA);


When using the uTasker simulator there is a further advantage since the macros include a call to the port simulator which will ensure that any consequences of changes with be handled (eg. updating port display in the simulator through to triggering interrupts or ADC triggers etc...)

Regards

Mark

See also http://www.utasker.com/forum/index.php?topic=539.0

Title: Re: GPIO Setting for PORTTA
Post by: frank on November 10, 2009, 05:06:18 PM
Thanks Mark. I tried to read the input value of PORTTA using _READ_PORT(TA ). It is always returning 0x0F. 0xF seems to be the default value from the location SETTA.

But in my custom board, the PORRTA is connected to another chipset which feeds different values onto the PORTTA pins. 
Title: Re: GPIO Setting for PORTTA
Post by: mark on November 10, 2009, 09:37:21 PM
Hi Frank

As long as the port is neither configured as an output nor a peripheral function you should be able to read the pin state via the PORTIN_SETTA register.

Try connecting with the debugger and checking the registers and the value seen in this register when the port value is changed between '0' and '1'. You will need to refresh the display between changes (simply performing a single step in a program is adequate).

Regards

Mark
Title: Re: GPIO Setting for PORTTA
Post by: frank on November 17, 2009, 11:10:59 AM
Thanks Mark. that make sense.

Also, I would like to use PORTUA  register (as input ) for GPIO functionality. It looks like this register has already been used in uTasker code ( fnConfigSCI ).  My early test result shows me that setting this register content ( also in PUAPAR ) with 0x00 affects FTP sessions.  Is that right ?.
Title: Re: GPIO Setting for PORTTA
Post by: frank on November 17, 2009, 03:32:35 PM
Is there any document available which describes which GPIO registers are already used for primary function in uTasker project ?.
Title: Re: GPIO Setting for PORTTA
Post by: mark on November 17, 2009, 07:59:14 PM
Hi Frank

There is no document defining which ports are used for peripherals because this is very configuration dependent (for example the UART lines can also be configured to different ports in some cases, or no UARTs are used if SERIAL_INTERFACE is disabled). In fact the easiest method of checking how the ports/peripherals are configured is to run the project in the uTasker simulator. Then the states and uses are immediately visible when the simulator is run!!

Regards

Mark