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.

TMS570LC4357: Setting wrong in pinmux and N2HET module

Part Number: TMS570LC4357


Hi:

    I want to set physical pin "D3" as input GPIO and this pin has two functions which are "N2HET2[12]" and "MIBSPI2NENA".

    In this point, here codes below  are the setting of "pinmux" module and "N2HET[12]" module:

    pinmux:

pinMuxReg->PINMUX[97] = SIGNAL_N2HET2_12_D3 | SIGNAL_N2HET2_13_D2 | SIGNAL_N2HET2_14_D1 | SIGNAL_N2HET2_15_K4; // n2het2[12]
....
....
	PINMUX_GATE_EMIF_CLK_ENABLE(ON);
	PINMUX_EMIF_OUTPUT_ENABLE(ON);
	PINMUX_GIOA_DISABLE_HET1_ENABLE(OFF);
    PINMUX_GIOB_DISABLE_HET2_ENABLE(OFF);
    PINMUX_ETHERNET_SELECT(MII);
    PINMUX_ALT_ADC_TRIGGER_SELECT(1);

   N2HET[12]:

   hetREG2->DOUT = (uint32)((uint32)0U << 12U);
   hetREG2->DIR = (uint32) 0x00000000U; // all pin are input
   hetREG2->PDR = (uint32) 0x00000000U;// Set HET pins open drain enable
   hetREG2->PULDIS = (uint32) 0x00000000U;//Set HET pins pullup/down enable
   hetREG2->PSL = (uint32) 0x00000000U;//Set HET pins pullup/down select 
   hetREG2->HRSH = (uint32) 0x00001000U;//Set HET pins high resolution share
   hetREG2->AND = (uint32) 0x00000000U; //- Set HET pins AND share 
   hetREG2->XOR = (uint32) 0x00000000U;//Set HET pins XOR share
    /** - Setup prescaler values
    *     - Loop resolution prescaler
    *     - High resolution prescaler
    */
    hetREG2->PFR = (uint32)((uint32) 6U << 8U)
                | ((uint32) 0U);

   /** - Parity control register
    *     - Enable/Disable Parity check
    */
    hetREG2->PCR = (uint32) 0x00000005U;
    (void)memcpy((void *)hetRAM2, (const void *)het2PROGRAM, sizeof(het2PROGRAM));
    hetREG2->PFR = (uint32)((uint32) 6U << 8U)
                | ((uint32) 0U);
    hetREG2->INTENAC = 0xFFFFFFFFU;
    hetREG2->GCR = ( 0x00000001U 
                   | (uint32)((uint32)0U << 24U)
	               | (uint32)((uint32)1U << 16U)
                   | (0x00020000U));

    The aim is to set D3 as GPIO input pin, so I set D3 as N2HET[12]. and the logic here I want to realize is below.

if ((gioPORT->DIN & (0x1 << FORCED_UPDATE_PIN)) == 0)
	{
	   do_uart_update();
	}
else
   {
    do_nothing;
   }

The result is that when I gave 3.3V voltage to D3, there is nothing happend, is there anything wrong in my setup?

  • Hello,

    The pinmux configuration is correct. 

    If you want to use N2HET2[12] as GPIO, the N2HET2[12] should not be used in the N2HET code running in NHET RAM:

    You can use GIO APIs to control the N2HET pin:

    for example, gioToggleBit(hetPORT2, 12); --> toggle N2HET2[12]

    You can not use GIO port pointer to access N2HET register:

    if ((gioPORT->DIN & (0x1 << FORCED_UPDATE_PIN)) == 0)

    Please change to:

    if((hetPORT2->DIN & (0x1 << 12)) == 0)  --> if N2HET2[12] is LOW

  • thanks,QJ. 

    1. I think I need change PWM2 pin 12 to other number.

    2. Do I need this code (void)memcpy((void *)hetRAM2, (const void *)het2PROGRAM, sizeof(het2PROGRAM));?

    3. Use this logic "if((hetPORT2->DIN & (0x1 << 12)) == 0)"

  • Hi,QJ

    1. I changed the PWM2 pin from 12 to 13, and use logic as "if((hetPORT2->DIN & (0x1 << 12)) == 1)" then do something, but it still not worked.

    2. Then I comment the (void)memcpy((void *)hetRAM2, (const void *)het2PROGRAM, sizeof(het2PROGRAM));,but it still not worked.

  • If you don't use NHET to output PWM, and to capture input etc, you don't need to copy the NHET code to NHET RAM:

       // (void)memcpy((void *)hetRAM2, (const void *)het2PROGRAM, sizeof(het2PROGRAM));

    Do you provide input to N2HET2[12] (pin D3)?