MCF52235EVB Ethernet doesn´t work

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCF52235EVB Ethernet doesn´t work

3,783 Views
Student_Exams
Contributor I
Hello

i know that there are various post on the same theme, but i´´m really helpless.
i´m working on the evalboard and just want to send an ethernetpacket.
in my opinion i did everything what is necessary. i compared my code with examples and talked to friends of mine but without success.
i really hope that you can spend a plenty of time to view at my sourcecode. i used the standard support files and the cfinit to make sure everything is correct, but after setting the TDAR nothing happens.
maybe the problem is the MMFR but i have no idea.

thx for any clues

here is the c code. i know its a lot but....i left out the nonessential parts

static unsigned char  mac[6] = { 0x00, 0x6B, 0x5D, 0x40, 0xF8, 0xDC };
static unsigned char dest[6] = { 0x00, 0x60, 0x08, 0x47, 0xEE, 0x56 };

void nbuf_init ()
{
    uint8 i;

    TxNBUF = (NBUF *)((uint32)(unaligned_txbd + 16) & 0xFFFFFFF0);
    RxNBUF = (NBUF *)((uint32)(unaligned_rxbd + 16) & 0xFFFFFFF0);
    TxBuffer = (uint8 *)((uint32)(unaligned_txbuffer + 16) & 0xFFFFFFF0);
    RxBuffer = (uint8 *)((uint32)(unaligned_rxbuffer + 16) & 0xFFFFFFF0);

    for (i = 0; i < NUM_RXBDS; i++)
    {
        RxNBUF[i].status = RX_BD_E;
        RxNBUF[i].length = 0;
        RxNBUF[i].data = &RxBuffer[i * RX_BUFFER_SIZE];
    }
    RxNBUF[NUM_RXBDS - 1].status |= RX_BD_W;

    for (i = 0; i < NUM_TXBDS; i++)
    {
        TxNBUF[i].status = TX_BD_L | TX_BD_TC;
        TxNBUF[i].length = 0;
        TxNBUF[i].data = &TxBuffer[i * TX_BUFFER_SIZE];
    }
    TxNBUF[NUM_TXBDS - 1].status |= TX_BD_W;

    iTxbd = iRxbd = 0;

    return;
}

int main()
{
    int i = 0;

    // Mask all interrupts
    asm {
        move.w   #0x2700,sr
    }
      
    MCF_FEC_ECR = MCF_FEC_ECR_RESET;
    while (MCF_FEC_ECR & MCF_FEC_ECR_RESET);
  
    MCF_FEC_EIMR = 0;
    MCF_FEC_EIR = 0xFFFFFFFF;
  
    MCF_FEC_RCR = MCF_FEC_RCR_MAX_FL(0x5ee) |
                  MCF_FEC_RCR_MII_MODE      |
                  MCF_FEC_RCR_PROM            |
                  MCF_FEC_RCR_DRT;

    MCF_FEC_TCR = 0;

    MCF_FEC_EIMR = 0xFFF80000;
    //MCF_FEC_EIMR_RXF   ;

    MCF_FEC_FRSR = 0x00000500;
    MCF_FEC_TFWR = 0;
    MCF_FEC_GAUR = 0;
    MCF_FEC_GALR = 0;
    MCF_FEC_IAUR = 0;
    MCF_FEC_IALR = 0;
    MCF_FEC_PALR = 0x5d40f8dc;
    MCF_FEC_PAUR = 0x006b0000;
  
    nbuf_init();
    MCF_FEC_EMRBR = ((uint16)RX_BUFFER_SIZE)*3;
    MCF_FEC_ERDSR = nbuf_get_start(Rx);
    MCF_FEC_ETDSR = nbuf_get_start(Tx);

    MCF_FEC_ECR = MCF_FEC_ECR_ETHER_EN;
  
    MCF_FEC_RDAR = 1;
   
    MCF_FEC_MSCR = MCF_FEC_MSCR_MII_SPEED(0xD);

    MCF_PHY_EPHYCTL1 = 0;

    MCF_PHY_EPHYCTL0 = MCF_PHY_EPHYCTL0_DIS100 |
                       MCF_PHY_EPHYCTL0_DIS10  |
                       MCF_PHY_EPHYCTL0_LEDEN;

    MCF_PHY_EPHYCTL0 &= ~MCF_PHY_EPHYCTL0_ANDIS;

    MCF_PHY_EPHYCTL0 |= MCF_PHY_EPHYCTL0_EPHYEN;

    MCF_PHY_EPHYCTL0 &= ~(MCF_PHY_EPHYCTL0_DIS100 |
                          MCF_PHY_EPHYCTL0_DIS10);

    cpu_pause(50000000)
 
    MCF_FEC_MMFR = MCF_FEC_MMFR_ST(0x1)      |
                  MCF_FEC_MMFR_OP(0x1)      |
                  MCF_FEC_MMFR_TA(0x2)      |
                  MCF_FEC_MMFR_DATA(0x2100);

    while ((MCF_FEC_EIR & MCF_FEC_EIR_MII) == 0);

    MCF_FEC_EIR |= MCF_FEC_EIR_MII;     init_ethernet_PHY ();
   
    init_interrupt_controller ();
   
    fec_init(&mein_nif);
    for(i=0; i<=5; i++)
        mein_nif.hwa[i] = mac[i];  
    nif_bind_protocol(&mein_nif, FRAME_ARP, stack_fechandler, "ARP_PROTOCOL" );
    nif_bind_protocol(&mein_nif, FRAME_IP, stack_fechandler, "IP_PROTOCOL" );

    MCF_INTC0_INTFRCL = 0x08000000; // tried to get an interrupt but no reaction...just went on in sourcecode

    //1. Paket
    eth_stub_init();
    eth_stub_txalloc(&mein_nif);
    for(i=0; i<=5; i++)
        eth_tx_frame.destination[i] = dest[i];
    for(i=0; i<=5; i++)
        eth_tx_frame.source[i] = mac[i];  
    eth_tx_frame.protocol = FRAME_IP;
    eth_tx_frame.frame_size = 0x64;
    eth_stub_writeheader(&mein_nif, &eth_tx_frame);  
    for(i=0; i<=100; i++)
        eth_stub_write(&mein_nif, 0xCC); //just some data to send
    eth_stub_send(&mein_nif, 0x64);

hope this is enough to find something
Labels (1)
0 Kudos
11 Replies

727 Views
mjbcswitzerland
Specialist V
Hi

It is difficult to analyse such code - one typing mistake or other things which are not visible could cause everthing to stop working but take hours to find.

I suggest that you do the following: Get a reference srec from this page for your EVB. http://www.utasker.com/software/software.html
Load it to your board - use the tutorial if you are new to this: http://www.utasker.com/docs/M5223X/uTaskerV1.3-Tutorial-M5223X_003.PDF
This will verify that your board is working correctly. There is then an FTP server installed on your board and you can then load the web pages (also on the SW side) to it.

If you fill out the application form http://www.utasker.com/Licensing/License.txt
you can receive complete project code free of charge (for educational and other non-commercial work). This will allow you to immediately have web server, ftp server, telnet, smtp, UARTs, CAN, I2C, DMA etc. working, including support for software uploads via Ethernet/Internet and various other stuff (like LCDs and keyboard). It includes the uTasker device simulator which allows you to test and learn all of the code on a PC - other PCs on the network can communicate with the simulated device as if it were real. The uTasker is used at a number of colleges and universities for teaching purposes and is certainly the easiest and best way for you to start and learn quickly. Development times on real project can also be dramatically cut using the simulator..

Good luck

regards

Mark Butcher

www.uTasker.com

0 Kudos

727 Views
Student_Exams
Contributor I
hey.

thanks for the response until now.
it is a little bit astonishing that the support files of freescale to include the fec doesn´t work in a proper way.
i´m studiing marks ethernetcode right now.
be sure that i´ll ask, if anything is still unclear.

so far...

by the way i attached my complete source code. feel free to have a look at it:smileywink:


Message Edited by Student@Exams on 2007-06-13 12:04 PM

Message Edited by Student@Exams on 2007-06-13 12:04 PM
0 Kudos

727 Views
mccPaul
Contributor I
Hi
 
It's a little harsh to say that the sample code doesn't work, but it doesn't take advantage of the TX and RX buffer descriptor rings designed into the 5223x (and other mcf CPUs) FEC.
 
In fact, the sample will work in the sense that it can send and receive frames, but it becomes difficult to use it to create an efficient stack because the TX and RX frame buffers are tied to particular buffer descriptors. In the link I posted earlier, you can see a discussion of how the sample architecture falls over when you construct a frame to send, but then discover that you need to send an ARP packet before the frame you just created.
 
Cheers,
 
Paul.
0 Kudos

727 Views
Student_Exams
Contributor I
Hi

I´m still working on my Ethernet Problem.
I don´t think that I have problems with the TX or RX Buffers. It seems to me that the MII doesn´t get clock signals or something like that.
I don´t know if it is wrong, but I configured some PINs in the GPIO Module to switch their functions to MII Signals...FEC_MDIO and so on
Code:
    // Pin assignments for port NQ    //     Pin NQ1 : External interrupt, /IRQ1    //     Pin NQ2 : FEC receive data FEC_RXD[3]    //     Pin NQ3 : FEC receive data FEC_RXD[2]    //     Pin NQ4 : EdgePort GPIO/IRQ    //     Pin NQ5 : FEC receive data FEC_RXD[1]    //     Pin NQ6 : FEC receive error, FEC_RXER    //     Pin NQ7 : EdgePort GPIO/IRQ    //     DDRNQ[DDRNQ7]   = 0     //     DDRNQ[DDRNQ6]   = 0     //     DDRNQ[DDRNQ5]   = 0     //     DDRNQ[DDRNQ4]   = 0     //     DDRNQ[DDRNQ3]   = 0     //     DDRNQ[DDRNQ2]   = 0     //     DDRNQ[DDRNQ1]   = 0     MCF_GPIO_DDRNQ = 0;    //     PNQPAR[PNQPAR7] = %01    //     PNQPAR[PNQPAR6] = %11    //     PNQPAR[PNQPAR5] = %11    //     PNQPAR[PNQPAR4] = %01    //     PNQPAR[PNQPAR3] = %11    //     PNQPAR[PNQPAR2] = %11    //     PNQPAR[PNQPAR1] = %01    MCF_GPIO_PNQPAR = MCF_GPIO_PNQPAR_PNQPAR7(0x1) |                      MCF_GPIO_PNQPAR_PNQPAR6(0x3) |                      MCF_GPIO_PNQPAR_PNQPAR5(0x3) |                      MCF_GPIO_PNQPAR_PNQPAR4(0x1) |                      MCF_GPIO_PNQPAR_PNQPAR3(0x3) |                      MCF_GPIO_PNQPAR_PNQPAR2(0x3) |                      MCF_GPIO_PNQPAR_PNQPAR1(0x1);
 
I really don´t know what to do, so I try anything as you can see.

Is it important to write to the MMFR? I just took the generated initialisation of the CFInit tool and added some sourcecode for the buffer descriptors.
0 Kudos

727 Views
Student_Exams
Contributor I
Ok. I just mentioned that my idea of configuring the io pins was wrong, because i use an the internal mii interface.

i created a project file for codewarrior. the only function is to send a simple packet.
i attach these files. maybe you have five minutes and can look at this "mysterium".
0 Kudos

727 Views
mccPaul
Contributor I
Hi
 
I don't use CodeWarrior and I don't have a 52235EVB connected up at the moment, so i can't easily check your code for you.
 
In my experience, the PHY does not need to be initialised, the defaults work just fine so you need not worry about sending commands over the MII bus.
 
If you want to figure out what is going on in your code, I think it will be easier for you to either study the steps that a _working_ example goes through, or you should write a very simple program to send a buffer.
 
If you want to see a working example, then look at the Coldfire TCPIP Lite stack that you can download from here:
 
 
If you just want to try it out, then I suggest that you write a routine to initialise the FEC (see section 18.4.2 and 18.4.4  in the reference manual), then create a buffer and buffer desrciptor ring (section 18.6), set the first buffer descriptor to point to your buffer and then set TDAR. The FEC should send your buffer as an Ethernet frame. If the contents of the buffer are a properly formed Ethernet frame, you can capture it with Ethereal.
 
There is no need to initialise or use any interrupts to try this out.
 
Paul.
0 Kudos

727 Views
Student_Exams
Contributor I
Hi

it´s really funny. I downloaded the code and tried to compile. Afterall I have 22 error messages "unexpected end of line"
it´s not my day today:smileywink:

The program i wrote is nearly exactly about what you´ve written.
Few minutes ago I tried internal loopback. No success.
0 Kudos

727 Views
Student_Exams
Contributor I
Hi.

I Just wanted to tell you that it´s working now.
It was no problem with the code. I changed the "Compiler Target" from "Console Debug" to "UART Debug".

In my opinion it has to work with both preferences...
I´m happy for the first time...:smileyhappy:
0 Kudos

727 Views
mccPaul
Contributor I
Thanks for letting us know!
 
It happens quite often that you are sure that everything is set up properly but what you are trying to do still doesn't work. That's why it is always good to go to an example that is known to work so that you can check the setup and hardware.
 
I've never used console debugging with Codewarrior or with GDB - to me it just adds more things that may go wrong, there is nothing like a serial console for simplicity!
 
Cheers,
 
Paul.
0 Kudos

727 Views
JasminG_
Contributor I
My MCF52235EVB and MCF52233DEMO work correctly on Ethernet but my design do not work.
I do the same electrical connection of 52233DEMO, with pulse H1102.
But the firmware work just in the evalboard, not on my design.
 
Any Body have a idea for help me.
 
Jasmin G.
0 Kudos

727 Views
mccPaul
Contributor I
Hi
 
I'd have to agree with Mark - your best course of action will be to study an existing _working_ FEC driver to learn how the FEC works.
 
I know you haven't posted all your code, but it looks like the FreeScale example that I have seen before that doesn't actually use the FEC properly! You will be much better off studying Mark's uTasker stack, or the NicheLite stack (which does come with a few bugs documented on the forum). See this thread for a detailed discussion of how the FEC works and problems with the example code: http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&message.id=2336#M2336.
 
The reference manual chapter on the FEC is your friend here - look at the the FEC driver in one of the examples mentioned alongside the manual. You need to understand how the FEC is initialised - the easy part, and how the transmit and receive buffer descriptors are used - more difficult to get your head around. It is possible to write a minimalist driver that can transmit a frame with using interrupts, but for anything sensible you need a good understanding of the ColdFire interrupt controller.
 
Please feel free to ask more questions - even if they seem trivial - as the answers will help others as well.
 
Cheers,
 
Paul.
 
edited to remove stupid automatic :smileysad:    :smileymad:


Message Edited by mccp on 2007-06-13 09:27 AM
0 Kudos