This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS3137: Regarding N2HET1 PORT GPIO Controlling.

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Tool/software:

Dear All.

I'm trying to control GPIO using N2HET1 Port.

static void vSetHetGioOutputPort(uint32 pinNum, boolean lowHigh)
{
uint32 currentPortValue = gioGetPort(hetPORT1);

if(lowHigh) {
gioSetPort(hetPORT1, currentPortValue | (1U << pinNum));
}
else {
gioSetPort(hetPORT1, currentPortValue & (~(1U << pinNum)));
}
}

I wrote the control function as above. The pinNum will have the value 31 and lowHigh will control the gpio to High/Low.

Is the function written correctly? Please check.

  • Hi INBUM LEE,

    static void vSetHetGioOutputPort(uint32 pinNum, boolean lowHigh)
    {
    uint32 currentPortValue = gioGetPort(hetPORT1);

    if(lowHigh) {
    gioSetPort(hetPORT1, currentPortValue | (1U << pinNum));
    }
    else {
    gioSetPort(hetPORT1, currentPortValue & (~(1U << pinNum)));
    }
    }

    Seems like you want to toggle the GPIO pin,

    For toggling purpose, you can simply call the gioToggleBit API, instead of reading existing status and changing the bit value, i mean you call something like below:

    Here is the complete example:

    1464.SCI_AND_LED_Blink_TEST_LS3137.zip

    --
    Thanks & regards,
    Jagadish.

  • Dear Jagadish.

    The gioToggleBit function is already used in LED.
    The function I mentioned is the function that I want to controll Low/High depending on the situation.
    Is it possible to controll HET Port with the sample code I mentioned?

    best regards,
    IBLEE

  • Actually, I raised pin 31 of N2Het1 to high with the sample code I mentioned, but the board died with portError. I asked to check if it was a pin control issue or another issue.

  • Hi INBUM LEE,

    The gioToggleBit function is already used in LED.
    The function I mentioned is the function that I want to controll Low/High depending on the situation.
    Is it possible to controll HET Port with the sample code I mentioned?

    I don't see any issues with your sample code, yes you can use this code to control the Low/High.

    Actually, I raised pin 31 of N2Het1 to high with the sample code I mentioned, but the board died with portError. I asked to check if it was a pin control issue or another issue.

    This should not happen with your code,

    Please make sure that you configured the pin-31 direction as output.

    If you are configuring pin direction as output in HALCoGen like as i mentioned above, then you should call the hetInit in your initialization code like below for to call actual direction modification.

    --
    Thanks & regards,
    Jagadish.

  • In summary,
    1. Set Port In/Out in Halcogen.
    2. Execute hetInit() function when hw initialize.
    3. Controll the pins using the sample code I mentioned.

    Is that right?

  • static void vInitHetPortToGio(void)
    {
    gioSetDirection(hetPORT1, 0xFFFBBFFFU);

    vSetHetGioOutputPort(HET_V1_TX_LED_PIN, pdFALSE);
    vSetHetGioOutputPort(HET_V2_RX_LED_PIN, pdFALSE);
    vSetHetGioOutputPort(HET_V1_RX_LED_PIN, pdFALSE);
    #if 0
    vSetHetGioOutputPort(HET_READY_RECEIVE_TESTTELEGRAM, pdTRUE);
    #else
    vSetHetGioOutputPort(HET_FPGA_IRQ_OUT, pdFALSE);
    #endif
    vSetHetGioOutputPort(HET_MCU_RELAY_CHECK_OUT, pdFALSE);
    }

    Actually, I executed the above initialize code when I initialized hw. Can I execute the above initialize code without modifying the port in Halcogen?

  • In summary,
    1. Set Port In/Out in Halcogen.
    2. Execute hetInit() function when hw initialize.
    3. Controll the pins using the sample code I mentioned.

    Is that right?

    You are totally correct,

    I want to add one more thing that is,

    You should call gioSetBit, gioSetPort and gioToggleBit API's for only the pins which are configured as outputs. We should not call these functions for the pins which are inputs.

    Get API's can be called for both input and output there won't be any issue here.

    --
    Thanks & regards,
    Jagadish.

  • Can I execute the above initialize code without modifying the port in Halcogen?

    Sorry i don't get this point.

    However, make sure you are following this:

    I want to add one more thing that is,

    You should call gioSetBit, gioSetPort and gioToggleBit API's for only the pins which are configured as outputs. We should not call these functions for the pins which are inputs.

    Get API's can be called for both input and output there won't be any issue here.

    --
    Thanks & regards,
    Jagadish.

  • The current sequence I have implemented is...

    1. Do not call hetInit()
    2. Do not set Pin in/out in Halcogen
    3. Set direction like this at boot time: gioSetDirection(hetPORT1, 0xFFFBBFFFU);
    4. Controll port with the function I mentioned at the beginning (vSetHetGioOutputPort)

    I have implemented it like this now,
    but you are saying that I should do it like below?
    1. Set Port In/Out in Halcogen.
    2. Execute hetInit() function when hw initialize.
    3. Controll the pins using the sample code I mentioned.

    Best Regards,
    IBLEE

  • Hi IBLEE,

    The current sequence I have implemented is...

    1. Do not call hetInit()
    2. Do not set Pin in/out in Halcogen
    3. Set direction like this at boot time: gioSetDirection(hetPORT1, 0xFFFBBFFFU);
    4. Controll port with the function I mentioned at the beginning (vSetHetGioOutputPort)

    I have implemented it like this now,
    but you are saying that I should do it like below?
    1. Set Port In/Out in Halcogen.
    2. Execute hetInit() function when hw initialize.
    3. Controll the pins using the sample code I mentioned.

    Both should work, try both methods and update the result so that we can further dig into the issue.

    --
    Thanks & regards,
    Jagadish.

  • Dear Jagadish.

    I fully understand the software coding part you mentioned.

    However, when I test it on the target board now, it seems that the hw reset is triggered when I change the het1[31] pin from Low to High.

    The applied sequence is as follows.
    1. halcogen -> N2Het1 tab -> Set input/output pins from pin 0~7 to pin 24~31
    2. Call hetInit() in the hwInit section
    3. Use the code below in a specific code
    static void vSetHetGioOutputPort(uint32 pinNum, boolean lowHigh)
    {
    //uint32 currentPortValue = gioGetPort(hetPORT1);

    if(lowHigh) {
    //gioSetPort(hetPORT1, currentPortValue | (1U << pinNum));
    gioSetBit(hetPORT1, pinNum, 1); }
    else {
    //gioSetPort(hetPORT1, currentPortValue & (~(1U << pinNum)));
    gioSetBit(hetPORT1, pinNum, 0);
    }
    }

    I really don't know what I'm doing wrong.

    Can you help me?

    I'm trying to use all het1 ports on the target board as GPIOs,
    and I'm trying to use 14, 18 as input ports,
    and 16, 17, 19, 20, 22, 25, 26, 27, 31 as output ports.

    Can you tell me the halcogen settings for using them as gpio ports?

    best regards,
    IBLEE

  • Dear Jagadish.

    What I'm curious about is,
    1. Does the pin setting of the "Pwm 0-7" tab have any relation?
    2. Does the pin setting of the "Edge 0-7" tab have any relation?
    3. Does the pin setting of the "Cap 0-7" tab have any relation?
    4. Shouldn't the "Bit Hr Share" part of the "Pin 0-31" tab be connected downwards to use each of the 32 gpios?

    Best regards,

    IBLEE

  • Hi IBLEE,

    Apologies for the delay.

    However, when I test it on the target board now, it seems that the hw reset is triggered when I change the het1[31] pin from Low to High.

    This should not happen, and it should not be a software issue.

    Make sure the pin is not shorted with GND.

    Which board you are using? Try to test the same code with another board and see whether you are facing the same issue or not.

    --
    Thank s& regards,
    Jagadish.