RIO BL70 set to output

When i set the BL70 to output, it stay ON for 100ms and then off again. Other port such as BL50-BL53 are ok
here is the codes. Do you have any ideas? Please help

void setDigitalOutput(int channel,int onOff)
{

switch (channel)
{
case DO_0:
    WrPortE(0x0a,NULL,0x0d);//port 5 bit 1
    if (onOff==TRUE)
        WrPortE(0x0b,NULL,0x07);//port 5 bit 1 on
    else
        WrPortE(0x0b,NULL,0x06);//port 5 bit 1 off
    break;
case DO_1:
    WrPortE(0x0a,NULL,0x0e);//port 5 bit 2
    if (onOff==TRUE)
        WrPortE(0x0b,NULL,0x07);//port 5 bit 2 on
    else
        WrPortE(0x0b,NULL,0x06);//port 5 bit 2 off
    break;
case DO_2:
    WrPortE(0x0a,NULL,0x0f);//port 5 bit 3
    if (onOff==TRUE)
        WrPortE(0x0b,NULL,0x07);//port 5 bit 1 on
    else
        WrPortE(0x0b,NULL,0x06);//port 5 bit 1 off
    break;
case DO_3:
    WrPortE(BL6,NULL,P0CR);//port 6 bit 1
    if (onOff==TRUE)
        WrPortE(IR6,NULL,0x07);//port 6 bit 1 on
    else
        WrPortE(IR6,NULL,0x06);//port 6 bit 1 off
    break;
}

}

/*** BeginHeader /
#ifndef __HINE_HA_GEN_II_ELEVATOR2_LIB
#define __HINE_HA_GEN_II_ELEVATOR2_LIB
/
** EndHeader */

/* START LIBRARY DESCRIPTION ************************************************
HINE_HA_GEN_II_ELEVATOR2.LIB
DESCRIPTION:
This library was generated by the Rabbit 4000 I/O LIB Utility.
If it is modified in any incorrect way it might not load properly.
Usage:
#use “HINE_HA_GEN_II_ELEVATOR2.LIB”
main()
{
BoardInit();

}

SUPPORT LIBRARIES: none
END DESCRIPTION *************************************************************/

/*** BeginHeader BoardInit /
void BoardInit();
void ClockCheck();
void SetupSerial();
#define BINBUFSIZE 31
#define BOUTBUFSIZE 31
#define SERB_TXPORT PCDR
#define BDRIVE_TXD 4
#define SERB_RXPORT PCDR
#define BDRIVE_RXD 5
#define CINBUFSIZE 31
#define COUTBUFSIZE 31
#define SERC_TXPORT PCDR
#define CDRIVE_TXD 2
#define SERC_RXPORT PCDR
#define CDRIVE_RXD 3
#define DINBUFSIZE 31
#define DOUTBUFSIZE 31
#define SERD_TXPORT PCDR
#define DDRIVE_TXD 0
#define SERD_RXPORT PCDR
#define DDRIVE_RXD 1
/
** EndHeader */

/* START FUNCTION DESCRIPTION ***********************************************
BoardInit <HINE_HA_GEN_II_ELEVATOR2.LIB>
END DESCRIPTION *************************************************************/

void ClockCheck()
{
if (freq_divider != 265) // 81.50 MHz, doubled
{
exception(-ERR_LIBCLOCKSPEED);
}
}

void SetupSerial()
{
serBopen(10187500L);
serCopen(10187500L);
serDopen(10187500L);
}

void BoardInit()
{
//ClockCheck();
// The following differ from BIOS settings
SetupSerial();
WrPortI(IB0CR,&IB0CRShadow,0x08); // Bank 0
WrPortI(PBDDR,&PBDDRShadow,0xFF); // Port B Input and output Pins
WrPortI(PCFR,&PCFRShadow,0x55); // Serial Port C
WrPortI(PDDDR,&PDDDRShadow,0x0F); // Port D Input and output Pins
WrPortI(PEDDR,&PEDDRShadow,0xD7); // Port E Input and output Pins
WrPortI(SACR,&SACRShadow,0x01); // Serial Port A
WrPortI(SPCR,&SPCRShadow,0x8C); // Port B Input and output Pins
}

// The following are used by the configuration utility
// Restore(SBCR, 0x01) // Serial Port B
// Restore(SCCR, 0x01) // Serial Port C
// Restore(SDCR, 0x01) // Serial Port D
// Restore(APIB, 0x01) // Serial Port B
// Restore(APIC, 0x01) // Serial Port C
// Restore(APID, 0x01) // Serial Port D
// Restore(BASE, 0x4DB9760) // Processor Options
// Restore(DBL, 0x01) // Processor Options
// Restore(USEPB, 0x01) // Serial Port B
// Restore(USEPC, 0x01) // Serial Port C
// Restore(USEPD, 0x01) // Serial Port D

/*** BeginHeader /
#endif
/
** EndHeader */
//checksum:842F

I’m not entirely sure about your WrPortE() function calls. You seem to be changing single bits, but not making use of a shadow register to ensure that you’re preserving the existing values of the other bits.

Is this entirely generated by the Rabbit I/O Lib Utility, or has it been modified?

Have you considered using RIO_SBC.LIB to interface with the RIO chip? It could be that you haven’t properly initialized the RIO for the way you’re using the I/O blocks.

i will try to use shadow register to see if it make any differrent. As you see in the code, DO_0…DO2 are ok and they are using the same method.

Anyway, we are using “Rabbit RIO Connections — Parallel Mode” circuit, Would it still work using RIO_SBC.lib

I haven’t used the RIO before, so I’m not intimately familiar with how to interface with it. I’ve read the datasheet and understand it a bit better. And I see that you don’t need to make use of shadow registers with those WrPortE() calls.

The code you provided shows using Port 6 Bit 0 for D0_3 (incorrectly labeled as Port 6 Bit 1). You didn’t share code for BL70, but I think it would be identical to the D0_3 case with BL6 replaced with BL7 and IR6 replaced with IR7.

I don’t understand why the D0_2 case uses values of 0x0a instead of BL5, 0x0b instead of IR5, and 0x0f instead of P3CR.

Is there anything in your code that would be calling setDigitalOutput() and resetting BL70 with some frequency? Are there other WrPortE() calls to address BL7 (0x0E) or IR7 (0x0F) that could be overwriting your settings?

Is this generated code or manually edited? Is it possible to re-generate code and see what it does for BL70?

I wondered if it was possible to configure the RIO to generate a single pulse when you toggle a pin to an on state, but it wasn’t clear if that was possible.

Hi Tom,
The original code was:
void setDigitalOutput(int channel,int onOff)
{

switch (channel)
{
case DO_0:
    WrPortE(0x0a,NULL,0x0d);//port 5 bit 1
    if (onOff==TRUE)
        WrPortE(0x0b,NULL,0x07);//port 5 bit 1 on
    else
        WrPortE(0x0b,NULL,0x06);//port 5 bit 1 off
    break;
case DO_1:
    WrPortE(0x0a,NULL,0x0e);//port 5 bit 2
    if (onOff==TRUE)
        WrPortE(0x0b,NULL,0x07);//port 5 bit 2 on
    else
        WrPortE(0x0b,NULL,0x06);//port 5 bit 2 off
    break;
case DO_2:
    WrPortE(0x0a,NULL,0x0f);//port 5 bit 3
    if (onOff==TRUE)
        WrPortE(0x0b,NULL,0x07);//port 5 bit 1 on
    else
        WrPortE(0x0b,NULL,0x06);//port 5 bit 1 off
    break;
case DO_3:
    WrPortE(0x0c,NULL,0x0c);//port 6 bit 1
    if (onOff==TRUE)
        WrPortE(0x0d,NULL,0x07);//port 6 bit 1 on
    else
        WrPortE(0x0d,NULL,0x06);//port 6 bit 1 off
    break;
}

}
I changed to the BL6 to better understanding, I do have userdefine for BL6 and IR7. I also copy the code for BL7.
I set the break point and make sure all state ON and never see it turn off

Thank you for you helps

Chi

void powerOn(int onOff)
{
//turns PWR_Enable on and off
WrPortE(0x0e,NULL,0x0c);//port 7 bit 0
if (onOff==TRUE)
WrPortE(0x0f,NULL,0x07);//port 7 bit 0 +24vdc on
else
WrPortE(0x0f,NULL,0x06);//port 7 bit 0 +24vdc off
}

#define BL0 0x00
#define BL1 0x02
#define BL2 0x04
#define BL3 0x06
#define BL4 0x08
#define BL5 0x0A
#define BL6 0x0C
#define BL7 0x0E
#define IR0 0x01
#define IR1 0x03
#define IR2 0x05
#define IR3 0x07
#define IR4 0x09
#define IR5 0x0B
#define IR6 0x0D
#define IR7 0x0F
#define P0CR 0x0C
#define P1CR 0x0D
#define P2CR 0x0E
#define P3CR 0x0F

Hi Tom,
I found the problem. I grep the project for WrPortE(0x0c,NULL,0x0c) and found another place that call to turn the bit off. you give the clue to find it . Thanks.

I want to get the interrupt working and wonder if you have time to help.

Thanks

I don’t have direct experience with configuring the RIO. I’d recommend reading through the RIO_SBC.LIB and trying to understand how it makes use of that feature.

You could also look at Samples/BL4S1xx/DIO/Interrupts.c or Samples/BLxS2xx/DIO/Interrupts.c to see how they interface interrupt handlers. I see that BL4S1xx has a button press example using interrupts.