Loop Compiling (PIC32MX795 and MRF24WB0M)

Discussion in 'Embedded Systems and Microcontrollers' started by FernandoS, Jun 5, 2011.

  1. FernandoS

    Thread Starter New Member

    Jun 5, 2011
    1
    0
    I've a custom board with PIC32MX795 and MRF24WB0M+pictail, using TCPIP Stack and Wifi Easyconfig in MPLAB 8.70.
    All the changes are made, Datasheet/hardware, TCP Wizard, TCPIP_Config.h, Hardware_profile.h, WF_Config.h...
    When finally compiling without errors... I've a Loop!!!
    As you can see below, when it comes to line 18, returns to line 1.
    I try and try and can't fix it. Can someone help me please...

    Copy of code with LOOP:

    ------------------------------------------------------------------------------------
    #elif defined( __PIC32MX__ )
    #define ClearSPIDoneFlag()
    static inline __attribute__((__always_inline__)) void WaitForDataByte( void )
    {
    ?1 while (!EEPROM_SPISTATbits.SPITBE || !EEPROM_SPISTATbits.SPIRBF);
    }

    #define SPI_ON_BIT (EEPROM_SPICON1bits.ON)
    --------------------------------------------------------------------------------------
    BOOL XEEIsBusy(void)
    {
    volatile BYTE_VAL result;
    BYTE vSPIONSave;
    #if defined(__18CXX)
    BYTE SPICON1Save;
    #elif defined(__C30__)
    WORD SPICON1Save;
    #else
    DWORD SPICON1Save;
    #endif

    // Save SPI state
    SPICON1Save = EEPROM_SPICON1;
    vSPIONSave = SPI_ON_BIT;

    // Configure SPI
    SPI_ON_BIT = 0;
    EEPROM_SPICON1 = PROPER_SPICON1;
    SPI_ON_BIT = 1;

    EEPROM_CS_IO = 0;
    // Send RDSR - Read Status Register opcode
    EEPROM_SSPBUF = OPCODE_RDSR;
    WaitForDataByte();
    ?2 result.Val = EEPROM_SSPBUF;

    // Get register contents
    ?3 EEPROM_SSPBUF = 0; ------------------------------------------ Return to ?1
    WaitForDataByte();
    ?4 result.Val = EEPROM_SSPBUF;
    ?5 EEPROM_CS_IO = 1;

    // Restore SPI State
    ?6 SPI_ON_BIT = 0;
    ?7 EEPROM_SPICON1 = SPICON1Save;
    ?8 SPI_ON_BIT = vSPIONSave;

    ?9 return result.bits.b0;
    }---------------------------------------------------------------------Go to ?10 (page down)
    ---------------------------------------------------------------------------------------------
    XEE_RESULT XEEEndWrite(void)
    {
    if(vBytesInBuffer)
    DoWrite();

    return XEE_SUCCESS;
    }

    static void DoWrite(void)
    {
    BYTE i;
    volatile BYTE vDummy;
    BYTE vSPIONSave;
    #if defined(__18CXX)
    BYTE SPICON1Save;
    #elif defined(__C30__)
    WORD SPICON1Save;
    #else
    DWORD SPICON1Save;
    #endif

    // Save SPI state
    SPICON1Save = EEPROM_SPICON1;
    vSPIONSave = SPI_ON_BIT;

    // Configure SPI
    SPI_ON_BIT = 0;
    EEPROM_SPICON1 = PROPER_SPICON1;
    SPI_ON_BIT = 1;

    // Set the Write Enable latch
    EEPROM_CS_IO = 0;
    EEPROM_SSPBUF = OPCODE_WREN;
    WaitForDataByte();
    vDummy = EEPROM_SSPBUF;
    EEPROM_CS_IO = 1;

    // Send WRITE opcode
    EEPROM_CS_IO = 0;
    EEPROM_SSPBUF = OPCODE_WRITE;
    WaitForDataByte();
    vDummy = EEPROM_SSPBUF;

    // Send address
    #if defined(USE_EEPROM_25LC1024)
    EEPROM_SSPBUF = ((DWORD_VAL*)&EEPROMAddress)->v[2];
    WaitForDataByte();
    vDummy = EEPROM_SSPBUF;
    #endif

    EEPROM_SSPBUF = ((DWORD_VAL*)&EEPROMAddress)->v[1];
    WaitForDataByte();
    vDummy = EEPROM_SSPBUF;

    EEPROM_SSPBUF = ((DWORD_VAL*)&EEPROMAddress)->v[0];
    WaitForDataByte();
    vDummy = EEPROM_SSPBUF;


    for(i = 0; i < vBytesInBuffer; i++)
    {
    // Send the byte to write
    EEPROM_SSPBUF = EEPROMBuffer;
    WaitForDataByte();
    vDummy = EEPROM_SSPBUF;
    }

    // Begin the write
    EEPROM_CS_IO = 1;

    // Update write address and clear write cache
    EEPROMAddress += vBytesInBuffer;
    vBytesInBuffer = 0;

    // Restore SPI State
    SPI_ON_BIT = 0;
    EEPROM_SPICON1 = SPICON1Save;
    SPI_ON_BIT = vSPIONSave;


    // Wait for write to complete
    ?10 while( XEEIsBusy() );
    }
    -------------------------------------------------------------------------------
    BOOL XEEIsBusy(void)
    {
    volatile BYTE_VAL result;
    BYTE vSPIONSave;
    #if defined(__18CXX)
    BYTE SPICON1Save;
    #elif defined(__C30__)
    WORD SPICON1Save;
    #else
    DWORD SPICON1Save;
    #endif

    // Save SPI state
    ?11 SPICON1Save = EEPROM_SPICON1;
    ?12 vSPIONSave = SPI_ON_BIT;

    // Configure SPI
    ?13 SPI_ON_BIT = 0;
    ?14 EEPROM_SPICON1 = PROPER_SPICON1;
    ?15 SPI_ON_BIT = 1;

    ?16 EEPROM_CS_IO = 0;
    // Send RDSR - Read Status Register opcode
    ?17 EEPROM_SSPBUF = OPCODE_RDSR;
    ?18 WaitForDataByte();-------------------------------Return to ?1

    ?2 result.Val = EEPROM_SSPBUF;
     
Loading...