Hi,
why is necessary to init the PIO (see code) too activate the Profibus state and error LED (N17,N18) :?:
When I dont configure the PIO, then the LED´s are always out.
You told me that the stack´s dont need PIO configuration´s.
STATIC CONST FAR RX_PIO_SET_T atrXPio[] = {
{{"SYSPIO",RX_PERIPHERAL_TYPE_PIO,0},
{RX_PIO_VALUE_TYPE_ACTIVE_HIGH,NETX_PIO_OUT_EN,0x000000030},
{RX_PIO_VALUE_TYPE_NONE,NULL,0x00000000},
{RX_PIO_VALUE_TYPE_ACTIVE_LOW,NETX_PIO_OUT},
{RX_PIO_VALUE_TYPE_ACTIVE_LOW,NETX_PIO_OUT},
{RX_PIO_VALUE_TYPE_ABSOLUTE,NETX_PIO_IN},
},
Br,
Rainer
Hi AJ,
Do you mean, that the PIO´s (36,37) are necessary for the LED´s
Br,
Rainer
Hilscher Gesellschaft fuer Systemautomation mbH
Hi,
all the Hilscher protocol stacks control the PIOs 0-7 for the fieldbus specific status LED's.
PIO 63,37 are HIF Pios!
Hi AJ,
Happy New Year :lol:
We have redesign our board and use PIO 12 - PiO 16 for digital output.
When I start the profibus stack then the PIO 12 goes from high to low, when the error LED for the profibus PIO 5 change.
The same behavior ocours with the devicenet stack.
That the stacks use PIO 12 - 16. You have wrote me that only PIO 0..7 are used by the stacks.
Br,
Rainer
Hilscher Gesellschaft fuer Systemautomation mbH
Hi Rainer,
:?: strange. Yes, all the stacks uses PIO 0..7.
How are the PIOs configured?
HI AJ,
My configuration over Syskernel
/*
************************************************************
* Configuration of the PIO Instances
************************************************************
*/// PIO für LED´s Profibus (4+5 für LED an Profibusstecker (0..7) werden für LED´s benutzt)
STATIC CONST FAR RX_PIO_SET_T atrXPio[] = {
{{"SYSPIO",RX_PERIPHERAL_TYPE_PIO,0},
{RX_PIO_VALUE_TYPE_ACTIVE_HIGH,NETX_PIO_OUT_EN,0x0000000FF},//03
{RX_PIO_VALUE_TYPE_NONE,NULL,0x00000000},
{RX_PIO_VALUE_TYPE_ACTIVE_LOW,NETX_PIO_OUT},
{RX_PIO_VALUE_TYPE_ACTIVE_LOW,NETX_PIO_OUT},
{RX_PIO_VALUE_TYPE_ABSOLUTE,NETX_PIO_IN},
},};
At runtime I change the PIO configuration:// -----------------------------------------------------------------
// Funktion : Konfiguriert die PIO Pin's für IO. -
// Übergabe : Keine -
// Rückgabe : Keine -
// -----------------------------------------------------------------
void PIO_Init(void)
{
pDPM_REG->IF_CONF0=0x40000000;
pDPM_REG->IO_MODE0=0x40000000;
pDPM_REG->IO_MODE1=0x40000000;
pDPM_REG->IO_DATA0=0x00000000;
pDPM_REG->IO_DATA1=0x00000000;
}// -----------------------------------------------------------------
// Funktion : Überprüfe POI -
// Übergabe io : Pio Nummer -
// Rückgabe : Gesetzt (TRUE) / Nicht gesetzt (FALSE) -
// -----------------------------------------------------------------
TLR_BOOLEAN PIOCheck( unsigned int io )
{
TLR_UINT32 ulVal;
if ((io>=0) && (io<32))
{
ulVal = PEEK(NETX_PIO_IN);
if (BITTRUE(ulVal,BIT(io&0x1F)))
return TRUE;
else
return FALSE;
}
else if((io>31)&&(io<64))
{
if (BITTRUE(pDPM_REG->IO_DATA0,BIT(io&0x1F)))
return TRUE;
else
return FALSE;
}
else if((io>63)&&(io<85))
{
if (BITTRUE(pDPM_REG->IO_DATA1,BIT(io&0x1F)))
return TRUE;
else
return FALSE;
}
else
return FALSE;
}// -----------------------------------------------------------------
// Funktion : Konfiguriere PIO als Ausgang -
// Übergabe io : IO Port Nr. -
// Rückgabe : Keine -
// -----------------------------------------------------------------
void PIOConfig_output( unsigned int io )
{
unsigned long ulVal;
if ((io>=0) && (io<32))
{
ulVal = PEEK(NETX_PIO_OUT_EN);
ulVal |=BIT((io&0x1F));
POKE(NETX_PIO_OUT_EN, ulVal);
//NETX_PIO_AREA
}
else if((io>31)&&(io<64))
pDPM_REG->IO_DRV_EN0|=BIT((io&0x1F));
else if((io>63)&&(io<85))
pDPM_REG->IO_DRV_EN1|=BIT(io&0x1F);
}// -----------------------------------------------------------------
// Funktion : Konfiguriere PIO als Eingang -
// Übergabe io : IO Port Nr. -
// Rückgabe : Keine -
// -----------------------------------------------------------------
void PIOConfig_input( unsigned int io )
{
TLR_UINT32 ulVal;
TLR_UINT8 bit_mask;
if ((io>=0) && (io<32))
{
ulVal = PEEK(NETX_PIO_OUT_EN);
bit_mask=BIT((io&0x1F));
ulVal &=~BIT((io&0x1F));
POKE(NETX_PIO_OUT_EN, ulVal);
//NETX_PIO_AREA
}
else if ((io>31)&&(io<64))
pDPM_REG->IO_DRV_EN0&=~BIT((io&0x1F));
else if((io>63)&&(io<85))
pDPM_REG->IO_DRV_EN1&=~BIT(io&0x1F);
}// -----------------------------------------------------------------
// Funktion : Setzt den Ausgang der über io adressiert wird -
// Übergabe io : IO Port Nr. -
// Rückgabe : Keine -
// -----------------------------------------------------------------
void PIOSet( unsigned int io )
{
unsigned long ulVal;
if ((io>=0) && (io<32))
{
ulVal = PEEK(NETX_PIO_OUT);
ulVal |=BIT((io&0x1F));
POKE(NETX_PIO_OUT, ulVal);
}
else if((io>31)&&(io<64))
pDPM_REG->IO_DATA0|=BIT(io&0x1F);
else if((io>63)&&(io<85))
pDPM_REG->IO_DATA1|=BIT(io&0x1F);
}// -----------------------------------------------------------------
// Funktion : Löscht den Ausgang der über io adressiert wird -
// Übergabe io : IO Port Nr. -
// Rückgabe : Keine -
// -----------------------------------------------------------------
void PIOClr( unsigned int io )
{
unsigned long ulVal;
if ((io>=0) && (io<32))
{
ulVal = PEEK(NETX_PIO_IN);
ulVal &=~BIT((io&0x1F));
POKE(NETX_PIO_OUT, ulVal);
}
else if((io>31)&&(io<64))
pDPM_REG->IO_DATA0&=~BIT((io&0x1F));
else if((io>63)&&(io<85))
pDPM_REG->IO_DATA1&=~BIT(io&0x1F);
}
Following PIO are configuration during startup:
PIO_Init();PIOConfig_output(T_ON_OFF_PIO); // T ON/OFF PIO 18
PIOClr(T_ON_OFF_PIO);
PIOConfig_output(BUSTENT_PIO); // /BUSTENT PIO 19
PIOConfig_output(BUSTENT_PB_PIO); // Profibus Busterminierungstreiber PIO 21
In a 10 ms timer i check the state of PIO 18. When the error led Pio5 change his state, the PIO 18 is zero, then I set it again to 1.
if (PIOCheck(T_ON_OFF_PIO)==FALSE)
{
PIOSet(BUSTENT_PB_PIO);
PIOSet(T_ON_OFF_PIO);
PIOClr(BUSTENT_PB_PIO);
}
I hope you can check it out.
Br,
Rainer
Hilscher Gesellschaft fuer Systemautomation mbH
Why are you not using the Driver Functions to configure and set the PIOs?
I think you have a problem in the PIO configuration.
Hi AJ,
I use the register, because it is easier to set and clear only one PIO.
Can I configure the PIO 4+5 for the stack LED direct over the
register e.g. PIOConfig_output(4); and set it with PIOSet(4)
Br,
Rainer
Hilscher Gesellschaft fuer Systemautomation mbH
That is not a good idea to try to control the stack LEDs by your self. In this case try to instances to set or clear the LEDs.
please check in the config file the LED instances.
/*
************************************************************
* Definition of the LED-Instances
************************************************************
*/
STATIC CONST FAR RX_LED_SET_T atrXLed[] =
{
{
{"DPS_RDY", RX_PERIPHERAL_TYPE_LED, 0},
{"SYSPIO", RX_PERIPHERAL_TYPE_PIO, 0},
{0},
{0},
{RX_LED_VALUE_TYPE_OR, 0, 0x10},
{RX_LED_VALUE_TYPE_OR, 0, 0x10},
Drv_PioSetupLedOperations,
},
{
{"DPS_ERR", RX_PERIPHERAL_TYPE_LED, 0},
{"SYSPIO", RX_PERIPHERAL_TYPE_PIO, 0},
{0},
{0},
{RX_LED_VALUE_TYPE_OR, 0, 0x20},
{RX_LED_VALUE_TYPE_OR, 0, 0x20},
Drv_PioSetupLedOperations,
}
}; Hi AJ,
When I configure the LED as you told me than the status LED is always on the error LED is always out.
Br,
Rainer
Hilscher Gesellschaft fuer Systemautomation mbH
Please remove for the test case your own PIO initialization.
Keep just the original one which was in the original delivered example.
Or test your application on a Hilscher development board and see if you have the same behavior.
Hi AJ,
I want to configure and set Pio´s over driver function. Here is my configuration and initialization:
// Configuration over Syskernel
static CONST FAR RX_PIO_SET_T atrXPio[] = {
{{"SW3_BIT0",RX_PERIPHERAL_TYPE_PIO,0},
{RX_PIO_VALUE_TYPE_ACTIVE_HIGH,NETX_PIO_OUT_EN,PIO_IN_DIRECTION}, /* Optional Register to make PIO Pin to output at startup */
{RX_PIO_VALUE_TYPE_NONE,NULL,0x00001000}, /* Optional Register to make PIO Pin to output at startup */
{RX_PIO_VALUE_TYPE_ACTIVE_LOW,NETX_PIO_OUT}, /* PIO Register to set PIOs */
{RX_PIO_VALUE_TYPE_ACTIVE_LOW,NETX_PIO_OUT}, /* PIO Register to clear PIOs */
{RX_PIO_VALUE_TYPE_ACTIVE_HIGH,NETX_PIO_IN}, /* Register to get current input value of the PIOs */
},
eRslt = Drv_PioIdentifyPio("SW3_BIT3", 0, &ptRsc->tRem.hSw3Bit3);
eRslt = Drv_PioInitializePio(ptRsc->tRem.hSw3Bit3);
// Set Output
eRslt = Drv_PioSetOutputs(ptRsc->tRem.hSw3Bit3,0x1000);
When I set the Ouptut with Drv_PioSetOutputs() , then the output are not set. What is missing in the configuration.
Br,
Rainer
Hilscher Gesellschaft fuer Systemautomation mbH
Hi Rainer,
- what are your used values for "NETX_PIO_OUT_EN" and "PIO_IN_DIRECTION"?
- try "{RX_PIO_VALUE_TYPE_NONE,NULL,0x00000000}, /* Optional Register to make PIO Pin to output at startup */"
- did you add the needed PIO driver into the atrXDrvCfgPost structure? ({DrvPioInit, RX_PERIPHERAL_TYPE_PIO,atrXPio,MAX_CNT(atrXPio)},)
- Did you get any error result back?
Hi AJ,
I try: "{RX_PIO_VALUE_TYPE_NONE,NULL,0x00000000},
did you add the needed PIO driver into the atrXDrvCfgPost structure? ({DrvPioInit, RX_PERIPHERAL_TYPE_PIO,atrXPio,MAX_CNT(atrXPio)},)
Yes I have
eRslt=Drv_PioSetOutputs(ptRsc->tRem.hSw3Bit3,0x1000);
value=PEEK(0x00100904); // PIO_OUT read
I get value=0. All results are 0.
What does the function drvPioInit() do ?
Br,
Rainer
Hilscher Gesellschaft fuer Systemautomation mbH
Hi Rainer,
the function "DrvPioInit()" initializes the PIO driver.
You have to do the following steps in this order:
- Drv_PioCreatePio
- Drv_PioIdentifyPio
- Drv_PioInitializePio
- Drv_PioSetOutputs/Drv_PioGetInputs
Hi Aj,
I initialized the PIO in this order.
Is there an example with PIO driver function on Hilscher Page available ?
Br,
Rainer
Hilscher Gesellschaft fuer Systemautomation mbH
Yes, there are.
Follow netX->Downloads->Application Examples->rcX Example
rcX-PIO Example. Describes how to control the output LEDs and the Input switch I1 - I8.
rcX Example. This examples describes how to configure two tasks.
Andreas Jacob
Hilscher Gesellschaft fuer Systemautomation mbH
Hi,
the stack controls the status LEDs like RDY/RUN COM/MNS.
If you use different PIOs you have to change the configuration for them, but you have to use the original names.