Help: Whole PORTC reading problems,PTC3 and PTC9 fail.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help: Whole PORTC reading problems,PTC3 and PTC9 fail.

Jump to solution
1,109 Views
patricio
Contributor IV

Hello,

I am having some problems when I try to read the whole PORTC. I find that PTC3 and PTC9 fail. 

I am working with a TWR-K64 board with KDS V3.2.0 and Processor Expert. 

I configured the whole PORTC as input, with pull up resistor enabled in each of the pins. The TWR-K64 board is not connected to any other board, so ifI read the PORTC value, I should read '1' in each of the pins of PORTC. However, PTC3 and PTC9 are always '0'.

The following pictures shows how the PORTC_PCRn register is configured:

PORTC_PCRn.png

         Bit PE = 1, pull enabled. 

         Bit PS = 1, internal pull-up selected. 

         Bits MUX = 001, pin mux control at Alt1(GPIO).

The following image shows GPIOC_PDDR register, and confirms that all of the pins are configured as inputs. 

However, the same image shows that when GPIOC_PDIR register is readed, PTC3 an PTC9 are '0'.

GPIOC_PDIR.png

Looking to the schematic of TWR-K64 I can not find any other connection of these two pins that would make to read them as '0', and neither in my code or Processor Expert configuration. 

What am I missing? Any help will be apreciated. 

BR.

1 Solution
992 Views
mjbcswitzerland
Specialist V

Hi

Ooops... my mistake, now I see you are using a standalone TWR-K64F120M instead

Therefore I just made a TWR-K64F120M version (running at 120MHz from IRC48). I also put the debug interface on USB-CDC due to the fact that the OpenSDA connection is otherwise on some PTC pins.

When the processor's USB interface is connected to a terminal emulator and ENTER is pressed it will print out the same info.

Now I get:

Serial number: 00
Software version V1.4.012
Device identification: KINETIS
Set PORT C to inputs
0x000ffdff

so I can confirm that at least one pin is at 0V (PTC9) - this was J26 (USB power switch).

After removing this I got

Serial number: 00
Software version V1.4.012
Device identification: KINETIS
Set PORT C to inputs
0x000fffff

For PTC3 you need to check J10. If it is set to 1-2 it will be '0'.

Serial number: 00
Software version V1.4.012
Device identification: KINETIS
Set PORT C to inputs
0x000ffff7

Therefore I expect that you have missed removing the jumpers.

I attached the binary again in case you don't manage to get the same results with your code.

Regards

Mark

View solution in original post

3 Replies
992 Views
mjbcswitzerland
Specialist V

Hi

I have attached  FRDM-K64F binary file that sets all port C pins to inputs with pull-ups, reads the level and prints the result to the UART (VCOM) at 115'200 Baud.

I get:

Hello, world... FRDM-K64F [External]
Static memory = 0x00000728
OS Heap use = 0x027d from 0xfc00
Initial stack margin 0x0000fb7c
Set PORT C to inputs
0x000fffff

You can also read the values in the I/O menu (command 3) with
"md 400ff090 l 1" [i.e. read one long work from address 0x400ff090 - PORTC_PDIR]

The code I used is (in uTasker Kinetis project)

_CONFIG_PORT_INPUT(C, (0xffffffff), PORT_PS_UP_ENABLE); // configure all port C pins as inputs with pull-up
fnDebugMsg("Set PORT C to inputs\r\n");
fnDebugHex(_READ_PORT(C), (sizeof(unsigned long) | WITH_LEADIN | WITH_CR_LF));

1, If you get different results with this binary you will need to check the signals on your board to see whether you have something different in the HW
2. If you get the same results it would point to a problem with the code that you are using.

Regards

Mark

0 Kudos
993 Views
mjbcswitzerland
Specialist V

Hi

Ooops... my mistake, now I see you are using a standalone TWR-K64F120M instead

Therefore I just made a TWR-K64F120M version (running at 120MHz from IRC48). I also put the debug interface on USB-CDC due to the fact that the OpenSDA connection is otherwise on some PTC pins.

When the processor's USB interface is connected to a terminal emulator and ENTER is pressed it will print out the same info.

Now I get:

Serial number: 00
Software version V1.4.012
Device identification: KINETIS
Set PORT C to inputs
0x000ffdff

so I can confirm that at least one pin is at 0V (PTC9) - this was J26 (USB power switch).

After removing this I got

Serial number: 00
Software version V1.4.012
Device identification: KINETIS
Set PORT C to inputs
0x000fffff

For PTC3 you need to check J10. If it is set to 1-2 it will be '0'.

Serial number: 00
Software version V1.4.012
Device identification: KINETIS
Set PORT C to inputs
0x000ffff7

Therefore I expect that you have missed removing the jumpers.

I attached the binary again in case you don't manage to get the same results with your code.

Regards

Mark

991 Views
patricio
Contributor IV

Hi Mark,

You were right: once removed the jumpers J26 and J10 everything was right.

Thank you for your help. 

Best regards. 

0 Kudos