• AVR Freaks

AnsweredHot!Does PLIB_PORTS_PinSet/Clear work in Harmony 3?

Author
DominusT
Super Member
  • Total Posts : 1401
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
2020/06/01 13:49:40 (permalink)
5 (1)

Does PLIB_PORTS_PinSet/Clear work in Harmony 3?

Hi.
 
I'm trying to migrate a project from H2 to H3 and I want to set a pin which controls an LED diode as follows:

 PLIB_PORTS_PinSet(PORTS_ID_0,PORT_CHANNEL_B,PORTS_BIT_POS_0); 

 
But I get the following error:



../src/appusb.c:113:31: note: each undeclared identifier is reported only once for each function it appears in
../src/appusb.c:113:42: error: 'PORT_CHANNEL_B' undeclared (first use in this function)

 
I have tried everything to fix it, but I am really frustrated.

Is there another way in H3 to do the same or what should I do to achieve it?
#1
NKurzman
A Guy on the Net
  • Total Posts : 18779
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/01 14:40:38 (permalink)
0
You should look at on of the example Projects that use the LEDs ( Like the USB MSD) and see how they did it.
 
#2
DominusT
Super Member
  • Total Posts : 1401
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/01 14:46:28 (permalink)
0
NKurzman
You should look at on of the example Projects that use the LEDs ( Like the USB MSD) and see how they did it.
 

Well it would be something similar to this:
LATBbits.LATB0 = 1;

#3
ric
Super Member
  • Total Posts : 27630
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/01 14:49:32 (permalink)
3 (2)
Can't you do precisely that?

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
DominusT
Super Member
  • Total Posts : 1401
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/01 14:52:34 (permalink)
0
ric
Can't you do precisely that?

I thought H3 kept 'abstraction' for writing or reading an I/O terminal.
Obviously if that is the solution, I should implement it.
#5
rjc101
Super Member
  • Total Posts : 129
  • Reward points : 0
  • Joined: 2016/07/08 14:56:34
  • Location: 0
  • Status: offline
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/01 14:53:44 (permalink)
0
Is you use the BSP in Harmony 3, you get something like...

/*** LED Macros for LED_DEBUG_1 ***/
#define LED_DEBUG_1_Toggle() (LATAINV = (1<<9))
#define LED_DEBUG_1_Get() ((PORTA >> 9) & 0x1)
#define LED_DEBUG_1_On() (LATACLR = (1<<9))
#define LED_DEBUG_1_Off() (LATASET = (1<<9))
 
#define VBUS_ON_PowerEnable() (LATBSET = (1<<5))
#define VBUS_ON_PowerDisable() (LATBCLR = (1<<5))

...for pins you have named and given a function to in the Pin Manager.  Or you can just the define macros yourself.
post edited by rjc101 - 2020/06/01 14:55:58
#6
DominusT
Super Member
  • Total Posts : 1401
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/01 15:15:22 (permalink)
4 (1)
rjc101
Is you use the BSP in Harmony 3, you get something like...

 
/*** LED Macros for LED_DEBUG_1 ***/
#define LED_DEBUG_1_Toggle() (LATAINV = (1<<9))
#define LED_DEBUG_1_Get() ((PORTA >> 9) & 0x1)
#define LED_DEBUG_1_On() (LATACLR = (1<<9))
#define LED_DEBUG_1_Off() (LATASET = (1<<9))
 
 
 
#define VBUS_ON_PowerEnable() (LATBSET = (1<<5))
#define VBUS_ON_PowerDisable() (LATBCLR = (1<<5))
 

...for pins you have named and given a function to in the Pin Manager.  Or you can just the define macros yourself.


Abstraction in H2 allows me to do the following:


void turnOFFOutput(void)
{
    char i;
    for(i = 0x00; i < 0x08; i++)
    {
       PLIB_PORTS_PinWrite(PORTS_ID_0,portOutput[i],bitsPortOutput[i],0x00);
     }
}


Where

static const PORTS_CHANNEL portOutput[] =
{
PORT_CHANNEL_F,
PORT_CHANNEL_B,
PORT_CHANNEL_B,
PORT_CHANNEL_B,
PORT_CHANNEL_B,
PORT_CHANNEL_B,
PORT_CHANNEL_E,
PORT_CHANNEL_B
};
static const PORTS_BIT_POS bitsPortOutput[] =
{
PORTS_BIT_POS_2,
PORTS_BIT_POS_2,
PORTS_BIT_POS_9,
PORTS_BIT_POS_1,
PORTS_BIT_POS_8,
PORTS_BIT_POS_10,
PORTS_BIT_POS_5,
PORTS_BIT_POS_15
};

 
But it seems that it must be done as before Harmony existed.
#7
NKurzman
A Guy on the Net
  • Total Posts : 18779
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/01 16:05:20 (permalink)
0
You could just make the same macro they did.
I would have to i used it everywhere

So how much effort is it to make a harmony 2 program harmony 3
#8
arpananand
Super Member
  • Total Posts : 495
  • Reward points : 0
  • Joined: 2009/11/18 04:35:42
  • Location: 0
  • Status: offline
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/02 04:26:48 (permalink) ☼ Best Answerby DominusT 2020/06/02 05:39:10
5 (2)
Harmony 3 has changed the API signature for such PORT operations. Harmony 2 was needing 2 arguments: channel name and pin position, whereas Harmony 3 needs only one argument, that is pin number.

so in H3, you can use following API:

GPIO_PinSet(GPIO_PIN pin) // for setting sinngle port pin
or
GPIO_PortSet(GPIO_PORT port, uint32_t mask); // for setting multiple pins of the same port channel together
#9
DominusT
Super Member
  • Total Posts : 1401
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
Re: Does PLIB_PORTS_PinSet/Clear work in Harmony 3? 2020/06/02 05:38:57 (permalink)
0
arpananand
Harmony 3 has changed the API signature for such PORT operations. Harmony 2 was needing 2 arguments: channel name and pin position, whereas Harmony 3 needs only one argument, that is pin number.

so in H3, you can use following API:

GPIO_PinSet(GPIO_PIN pin) // for setting sinngle port pin
or
GPIO_PortSet(GPIO_PORT port, uint32_t mask); // for setting multiple pins of the same port channel together

Thanks a lot for the suggestion:

GPIO_PinSet(GPIO_PIN_RB0);

#10
Jump to:
© 2020 APG vNext Commercial Version 4.5