0
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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();
\$\endgroup\$
  • \$\begingroup\$ This is what i was looking. I searched for "DATA_IN" and no result was found. Its clear now why... Thanks. \$\endgroup\$ – Nmaster88 Jun 13 at 13:09
0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Nmaster88 Jun 13 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.