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.

Calling "EMACPHYExtendedWrite" causes program termination

Other Parts Discussed in Thread: EK-TM4C1294XL

Hi,

  I want to modify Ethenet LED behavior by calling "EMACPHYExtendedWrite". My program is based on Tcp_echo example on EK-TM4C1294XL evaluation board. My modification is:

  Add code line "EMACPHYExtendedWrite(EMAC0_BASE, 0, 0x25, 0x0111)" before "EMAC_init()" in function "EK_TM4C1294XL_initEMAC", so the function is now like this:

void EK_TM4C1294XL_initEMAC(void)
{
uint32_t ulUser0, ulUser1;

/* Get the MAC address */
FlashUserGet(&ulUser0, &ulUser1);
if ((ulUser0 != 0xffffffff) && (ulUser1 != 0xffffffff)) {
System_printf("Using MAC address in flash\n");
/*
* Convert the 24/24 split MAC address from NV ram into a 32/16 split MAC
* address needed to program the hardware registers, then program the MAC
* address into the Ethernet Controller registers.
*/
macAddress[0] = ((ulUser0 >> 0) & 0xff);
macAddress[1] = ((ulUser0 >> 8) & 0xff);
macAddress[2] = ((ulUser0 >> 16) & 0xff);
macAddress[3] = ((ulUser1 >> 0) & 0xff);
macAddress[4] = ((ulUser1 >> 8) & 0xff);
macAddress[5] = ((ulUser1 >> 16) & 0xff);
}
else if (macAddress[0] == 0xff && macAddress[1] == 0xff &&
macAddress[2] == 0xff && macAddress[3] == 0xff &&
macAddress[4] == 0xff && macAddress[5] == 0xff) {
System_abort("Change the macAddress variable to match your boards MAC sticker");
}

GPIOPinConfigure(GPIO_PF0_EN0LED0); /* EK_TM4C1294XL_USR_D3 */
GPIOPinConfigure(GPIO_PF4_EN0LED1); /* EK_TM4C1294XL_USR_D4 */
GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);

EMACPHYExtendedWrite(EMAC0_BASE, 0, 0x25, 0x0111);   //line added. 0x25 is for LED_CFG

/* Once EMAC_init is called, EMAC_config cannot be changed */
EMAC_init();
}

It seems that an interrupt is trigger when the following code is executed in function "EMACPHYWrite", which is called by "EMACPHYExtendedWrite":

while(HWREG(ui32Base + EMAC_O_MIIADDR) & EMAC_MIIADDR_MIIB)
{
}

The following interrupt ISR is called :

ti_sysbios_family_arm_m3_Hwi_excHandlerAsm__I:
.asmfunc
tst lr, #4 ; context on PSP?
ite NE
mrsne r0, psp ; if yes, then use PSP
moveq r0, sp ; else use MSP

mov sp, r0 ; use this stack
stmfd sp!, {r4-r11} ; save r4-r11 while we're at it
mov r0, sp ; pass sp to exception handler
mov r1, lr ; pass lr too

ldr pc, excHandlerAddr

excHandlerAddr:
.word ti_sysbios_family_arm_m3_Hwi_excHandler__I
.endasmfunc

.end

It seems to be a hard fault.

Doesn't anybody know why? Thanks very much.

  • Hello Jianyi

    The most probable cause is that the Clock to EMAC and EPHY have not been enabled. Can you check the SYSCTL.RCGCEMAC register? If it is 0 then the above statement stands true.

    Else we would need some more info like the FAULTSTAT and FAULTADDR values.

    Regards

    Amit

  • Yes, it is 0. So shall I set it to 1 first?

  • Hi,

      I can add the code line "EMACPHYExtendedWrite(EMAC0_BASE, 0, 0x25, 0x0110)" at the end of function "EMACSnow_NIMUInit". In this function EMAC and EPHY are enabled:

    SysCtlPeripheralEnable(SYSCTL_PERIPH_EMAC0);
    SysCtlPeripheralReset(SYSCTL_PERIPH_EMAC0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_EPHY0);
    SysCtlPeripheralReset(SYSCTL_PERIPH_EPHY0);

     So can you please check if it is safe to add the line here? Or there are other things to do?

    Another problem now is that LED0/1/2 are always active high for chip revision 1/2/3. However, the standared design for ethenet green LED seems to be active low for indication of link OK. So shall we change the schematic design to be active high?

    Thanks

  • Hello Jianyi Bao,

    The EMAC Initialization is required to make sure that the PHY is correctly set up for communication. So my suggestion would be use the EMACInit as given in the sample programs before making changes to the PHY setting.

    The change for the same has been made on rev-2 and rev-3 to invert the polarity using the EMACCC register. So you do not need to change the mounting of the LED's

    Regards

    Amit

  • Hi, Amit

       OK, Thanks.