0

I'm more familiarized with MCC and with that framework is really easy to read a port we just need to give a custom name in pin module:

enter image description here

and after that in code:

DATA_IN_GetValue()

My question is how the same can be done in the Harmony framework because the label/name matters to me. I know we can read the ports with the overcomplicated function it has, but is there a way using the names?

I gave a name to the port here:

enter image description here

Nmaster88
  • 381
  • 5
  • 20

2 Answers2

1

If you give the port a name and a function and generate code... example...

enter image description here

You'll noticed that in system_config.h harmony only creates the following

/*** Functions for MY_TEST_PIN pin ***/
#define MY_TEST_PIN_PORT PORT_CHANNEL_E
#define MY_TEST_PIN_PIN PORTS_BIT_POS_6
#define MY_TEST_PIN_PIN_MASK (0x1 << 6)

which can be used as your parameters for PLIB_PORTS_PinGet, i.e.

PLIB_PORTS_PinGet (PORTS_ID_0, MY_TEST_PIN_PORT, MY_TEST_PIN_PIN)

You should probably define that in your application app.h to make it simpler

#define GET_MY_TEST_PIN() PLIB_PORTS_PinGet (PORTS_ID_0, MY_TEST_PIN_PORT, MY_TEST_PIN_PIN)

then somewhere where you want to get the pin value...

unsigned char MY_TEST_PIN_VALUE = GET_MY_TEST_PIN();
pm101
  • 505
  • 3
  • 13
  • This is what i was looking. I searched for "DATA_IN" and no result was found. Its clear now why... Thanks. – Nmaster88 Jun 13 '19 at 13:09
0

Why not use this:

#define   DATA_IN   RE6

value = DATA_IN;      

otherwise you could use this with harmony:

PLIB_PORTS_PinGet (PORTS_ID_0, PORT_CHANNEL_E, PORTS_BIT_POS_6)

or

PLIB_PORTS_PinGet (PORTS_ID_0, PORT_CHANNEL_E, DATA_IN)

but I guess it's much more complicated.

Mike
  • 2,146
  • 1
  • 14
  • 29
  • Hi @Mike, you mean ```PORTEbits.RE6```? In ```Pin Settings``` of Harmony, i define the name ```DATA_IN``` but is it not used anywhere? what's the point of defining that name then (in pin settings)? I can manually do the define in the code, but was hoping harmony did some kind of define for me. – Nmaster88 Jun 13 '19 at 11:43