CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ENC28J60 + 18f452 reset issue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ymoona



Joined: 20 Mar 2005
Posts: 32
Location: Heiloo, the Netherlands

View user's profile Send private message Visit poster's website

ENC28J60 + 18f452 reset issue
PostPosted: Sun Jul 26, 2009 10:28 am     Reply with quote

Hi,
I'm trying to get TCP/IP working on my PIC-WEB.
this is how my ccstcpip.h looks
Code:

//////////////////////////////////////////////////////////////////////////////
//
// ccstcpip.h - Common code shared among all Embedded Internet/Embedded
// Ethernet tutorial book examples.
//
// If you are using a CCS Embedded Ethernet Board (labeled PICENS, which
// has an MCP ENC28J60) then define STACK_USE_CCS_PICENS to TRUE.
//
// If you are using a CCS Embedded Internet Board (labeled PICNET, which
// has a Realtek RTL8019AS and a 56K Modem) then define STACK_USE_CCS_PICNET
// to TRUE.
//
//////////////////////////////////////////////////////////////////////////////
//
// 10/25/06
//  - Added STACK_USE_CCS_PICEEC
//  - ExampleUDPPacket[] UDP header length fixed
//
// 2008.12.20 - JGSCHMIDT
// - added STACK_USE_CCS_OLXMINI for Olimex Mini-Web board
//
//////////////////////////////////////////////////////////////////////////////

#define STACK_USE_CCS_PICENS     0 //18f4620 + enc28j60
#define STACK_USE_CCS_PICNET     0 //18f6722 + realtek
#define STACK_USE_CCS_PICEEC     0 //18f97j60
#define STACK_USE_CCS_OLXMINI    0 //Olimex Mini-Web 18f25j10 + enc28j60
#define STACK_USE_CCS_OLXWEB     1 //Olimex Pic-Web 18f452 + enc28j60

#if STACK_USE_CCS_PICENS
 #define STACK_USE_MCPENC 1
#endif

#if STACK_USE_CCS_OLXMINI
 #define STACK_USE_MCPENC 1
#endif

#if STACK_USE_CCS_OLXWEB
 #define STACK_USE_MCPENC 1
#endif

#if STACK_USE_CCS_PICEEC
 #define STACK_USE_MCPINC 1
#endif

#if STACK_USE_CCS_PICENS
 #include <18F4620.h>
 #use delay(clock=40M)
 #fuses H4, NOWDT, NOLVP, NODEBUG
 
#elif STACK_USE_CCS_PICNET
 #include <18F6722.h>
 #use delay(clock=40M)
 #fuses H4, NOWDT, NOLVP, NODEBUG
 
#elif STACK_USE_CCS_PICEEC
 #include <18F67J60.h>
 //#use delay(clock=41666667)
 //#fuses NOWDT, NODEBUG, H4_SW, NOIESO, NOFCMEN, PRIMARY
 #use delay(clock=25M)
 #fuses NOWDT, NODEBUG, HS, NOIESO, NOFCMEN, PRIMARY, ETHLED
 
#elif STACK_USE_CCS_PICNET_OLD
 #include <18F6720.h>
 #use delay(clock=20M)
 #fuses HS, NOWDT, NOLVP, NODEBUG
 #define STACK_USE_CCS_PICNET   TRUE

#elif STACK_USE_CCS_OLXMINI
 #include <18F25J10.h>
 #use delay(clock=40M, oscillator=10M)
 #fuses H4_SW, NOWDT, NODEBUG

#elif STACK_USE_CCS_OLXWEB
 #include <18F452.h>
 #use delay(clock=40000000)
 #FUSES NOWDT                    //No Watch Dog Timer
 #FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
 #FUSES H4                       //High speed osc with HW enabled 4X PLL
 #FUSES NOPROTECT                //Code not protected from reading
 #FUSES NOOSCSEN                 //Oscillator switching is disabled, main oscillator is source
 #FUSES BROWNOUT                 //Reset when brownout detected
 #FUSES BORV20                   //Brownout reset at 2.0V
 #FUSES NOPUT                    //No Power Up Timer
 #FUSES NOSTVREN                   //Stack full/underflow will cause reset
 #FUSES NODEBUG                  //No Debug mode for ICD
 #FUSES NOLVP                    //No Low Voltage Programming on B3(PIC16) or B5(PIC18)
 #FUSES NOWRT                    //Program memory not write protected
 #FUSES NOWRTD                   //Data EEPROM not write protected
 #FUSES NOWRTB                   //Boot block not write protected
 #FUSES NOWRTC                   //configuration not registers write protected
 #FUSES NOCPD                    //No EE protection
 #FUSES NOCPB                    //No Boot Block code protection
 #FUSES NOEBTR                   //Memory not protected from table reads
 #FUSES NOEBTRB                  //Boot block not protected from table reads
 
 #else
 
 #error You need to define your custom hardware

#endif

#if STACK_USE_CCS_OLXMINI
 // There is no level-shifter (MAX3232) on the board so I could not
 // use the UART
 #use rs232(baud=9600, XMIT=PIN_A1, INVERT)
#elif STACK_USE_CCS_OLXWEB
 #use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stop=1)
#else
 #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif

#include "tcpip/stacktsk.c"    //include Microchip TCP/IP Stack

#if STACK_USE_CCS_PICENS
 #include "tcpip/mlcd.c"
 #define BUTTON1_PRESSED()  (!input(PIN_A4))
 #define USER_LED1    PIN_A5
 #define USER_LED2    PIN_B4
 #define USER_LED3    PIN_B5
 #define LED_ON       output_low
 #define LED_OFF      output_high
 #define STANDARD_ADC_STRING  "AN0"
 #define STANDARD_ADC_CHANNEL 0
 void init_user_io(void) {
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_adc_ports(AN0);
   *0xF92=(*0xF92 & 0xDF) | 0x11;   //a5 output, a4 and a0 input
   *0xF93=*0xF93 & 0xCF;   //b4 and b5 output
   LED_OFF(USER_LED1);
   LED_OFF(USER_LED2);
   LED_OFF(USER_LED3);
   set_adc_channel(0);
 }

#elif STACK_USE_CCS_PICEEC
 #include "tcpip/elcd.c"
 #define BUTTON1_PRESSED()  (!input(PIN_A4))
 #define USER_LED1    PIN_B3
 #define USER_LED2    PIN_B4
 #define USER_LED3    PIN_B5
 #define LED_ON       output_low
 #define LED_OFF      output_high
 #define STANDARD_ADC_STRING  "AN2"
 #define STANDARD_ADC_CHANNEL 2
 void init_user_io(void) {
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_adc_ports(AN0_TO_AN2);
   set_adc_channel(2);
   *0xF92=*0xF92 & 0xFC;   //a0 and a1 output
   *0xF93=*0xF93 & 0xC7;   //b3, b4 and b5 output
   LED_OFF(USER_LED1);
   LED_OFF(USER_LED2);
   LED_OFF(USER_LED3);
   set_adc_channel(2);
 }

#elif STACK_USE_CCS_OLXMINI            // JGS 2008.12.20
// #include "tcpip/elcd.c"
 #define BUTTON1_PRESSED()  (!input(PIN_B0))
 #define USER_LED1    PIN_C2
 #define LED_ON       output_low
 #define LED_OFF      output_high
// #define STANDARD_ADC_STRING  "AN2"
// #define STANDARD_ADC_CHANNEL 2

void init_user_io(void) {
//   setup_adc(ADC_CLOCK_INTERNAL);
//   setup_adc_ports(AN0_TO_AN2);
//   set_adc_channel(2);
//   *0xF92=*0xF92 & 0xFC;   //a0 and a1 output
//   *0xF93=*0xF93 & 0xC7;   //b3, b4 and b5 output
   LED_OFF(USER_LED1);
//   LED_OFF(USER_LED2);
//   LED_OFF(USER_LED3);
//   set_adc_channel(2);
 }

#elif STACK_USE_CCS_OLXWEB           
// #include "tcpip/elcd.c"
 #define BUTTON1_PRESSED()  (!input(PIN_B0))
 #define USER_LED1    PIN_D5
 #define LED_ON       output_low
 #define LED_OFF      output_high
// #define STANDARD_ADC_STRING  "AN2"
// #define STANDARD_ADC_CHANNEL 2

void init_user_io(void) {
//   setup_adc(ADC_CLOCK_INTERNAL);
//   setup_adc_ports(AN0_TO_AN2);
//   set_adc_channel(2);
//   *0xF92=*0xF92 & 0xFC;   //a0 and a1 output
//   *0xF93=*0xF93 & 0xC7;   //b3, b4 and b5 output
   LED_OFF(USER_LED1);
//   LED_OFF(USER_LED2);
//   LED_OFF(USER_LED3);
//   set_adc_channel(2);
 }
 
#else

 #include "tcpip/dlcd.c"
 #define BUTTON1_PRESSED()  (!input(PIN_B0))
 #define BUTTON2_PRESSED()  (!input(PIN_B1))
 #define USER_LED1    PIN_B2
 #define USER_LED2    PIN_B4
 #define LED_ON       output_low
 #define LED_OFF      output_high
 #define STANDARD_ADC_STRING  "AN0"
 #define STANDARD_ADC_CHANNEL 0
 void init_user_io(void) {
   setup_adc(ADC_CLOCK_INTERNAL );
   setup_adc_ports(ANALOG_AN0_TO_AN1);
   *0xF92=*0xF92 | 3;            //a0 and a1 input (for ADC)
   *0xF93=(*0xF93 & 0xEB) | 3;   //B0 and B1 input, B2 and B4 output
   LED_OFF(USER_LED1);
   LED_OFF(USER_LED2);
   set_adc_channel(0);
 }
#endif

void MACAddrInit(void) {
   MY_MAC_BYTE1=0;
   MY_MAC_BYTE2=2;
   MY_MAC_BYTE3=3;
   MY_MAC_BYTE4=4;
   MY_MAC_BYTE5=5;
   MY_MAC_BYTE6=6;
}

void IPAddrInit(void) {
   //IP address of this unit
   MY_IP_BYTE1=192;
   MY_IP_BYTE2=168;
   MY_IP_BYTE3=100;
   MY_IP_BYTE4=7;

   //network gateway
   MY_GATE_BYTE1=192;
   MY_GATE_BYTE2=168;
   MY_GATE_BYTE3=100;
   MY_GATE_BYTE4=1;

   //subnet mask
   MY_MASK_BYTE1=255;
   MY_MASK_BYTE2=255;
   MY_MASK_BYTE3=255;
   MY_MASK_BYTE4=0;
}


char ExampleIPDatagram[] = {
   0x45, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
   0x64, 0x11, 0x2A, 0x9D, 0x0A, 0x0B, 0x0C, 0x0D,
   0x0A, 0x0B, 0x0C, 0x0E
};

char ExampleUDPPacket[] = {
   0x04, 0x00, 0x04, 0x01, 0x00, 0x08, 0x00, 0x00,
   0x01, 0x02, 0x03, 0x04
};


My HARDWARE.H looks like this.
Code:

///////////////////////////////////////////////////////////////////////////
////                                                                   ////
////                         HARDWARE.H                                ////
////                                                                   ////
//// Hardware I/O definitions and TCP/IP stack configuration settings. ////
////                                                                   ////
//// These values will probably change with each application.          ////
////                                                                   ////
///////////////////////////////////////////////////////////////////////////
////                                                                   ////
//// RELEASE HISTORY:                                                  ////
////                                                                   ////
////    Jan 15, 2004: MODEM_RESPONSE_TIMEOUT and MODEM_CONNECT_TIMEOUT ////
////                  moved to here.                                   ////
////                                                                   ////
////    Jan 09, 2004: Initial Public Release                           ////
////                                                                   ////
///////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996,2004 Custom Computer Services           ////
//// This source code may only be used by licensed users of the CCS C  ////
//// compiler.  This source code may only be distributed to other      ////
//// licensed users of the CCS C compiler.  No other use, reproduction ////
//// or distribution is permitted without written permission.          ////
//// Derivative programs created using this software in object code    ////
//// form are not restricted in any way.                               ////
///////////////////////////////////////////////////////////////////////////
//
// 2008.12.20 - JGSCHMIDT
// - added STACK_USE_CCS_OLXMINI for Olimex Mini-Web board

#IFNDEF ___TCPIP_STACK_CONFIGURATION
#define ___TCPIP_STACK_CONFIGURATION


#ifndef STACK_USE_CCS_PICNET
#define STACK_USE_CCS_PICNET  FALSE
#endif

#ifndef STACK_USE_CCS_PICENS
#define STACK_USE_CCS_PICENS  FALSE
#endif

#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#if STACK_USE_CCS_PICNET || STACK_USE_CCS_PICEEC || STACK_USE_CCS_EWL3V
 #use fast_io(F)
#endif


//// VARIOUS MODEM SETTINGS.
   #DEFINE  MODEM_DCD         PIN_G3
   #DEFINE  MODEM_RESET       PIN_G4
   #define  MODEM_TX          PIN_G1
   #define  MODEM_RX          PIN_G2
   #DEFINE  MODEM_INIT_STR    "ATM1L3&K0"   //speaker on, volume high, no hw flow control
   #DEFINE  MODEM_DIAL_STR    "ATDT"
   #DEFINE  MODEM_BAUD_RATE   115200

   #DEFINE  MODEM_RESPONSE_TIMEOUT  2000     //time to wait for a response to an AT command (in ms)
   #DEFINE  MODEM_CONNECT_TIMEOUT   120000    //time to wait for modem to make a connection (in ms)


//// VARIOUS MAC/NIC SETTINGS.
   #if STACK_USE_CCS_PICNET
      //Latch and Directional control SFR locations for the 3 control pins
      #define NIC_RESET_LAT       LATE_RE7
      #define NIC_IOW_LAT         LATE_RE6
      #define NIC_IOR_LAT         LATE_RE5
      #define NIC_RESET_TRIS      TRISE_RE7
      #define NIC_IOW_TRIS        TRISE_RE6
      #define NIC_IOR_TRIS        TRISE_RE5

      //Latch and Directional control SFR locations for the 5bit address port
      #define NIC_ADDR_LAT        LATE
      #define NIC_ADDR_TRIS       TRISE

      //Latch, Directional and I/O SFR locations for the 8bit data port
      #define NIC_DATA_IO         PORTF
      #define NIC_DATA_LAT        LATF
      #define NIC_DATA_TRIS       TRISF

      //This macro takes an address and properly outputs it on the latch register, and sets proper pins to output.
      //Leaves other pins alone.
      #define WRITE_NIC_ADDR(a)   NIC_ADDR_LAT = (NIC_ADDR_LAT & 0xE0)|a; \
                                NIC_ADDR_TRIS = NIC_ADDR_TRIS & 0xE0
   #elif STACK_USE_CCS_PICENS
      #define PIN_ENC_MAC_SO  PIN_C4   // PIC <<<< ENC
      #define PIN_ENC_MAC_SI  PIN_C5   // PIC >>>> ENC
      #define PIN_ENC_MAC_CLK PIN_C3
      #define PIN_ENC_MAC_CS  PIN_D1
      #define PIN_ENC_MAC_RST PIN_D0
      #define PIN_ENC_MAC_INT PIN_B0
      #define PIN_ENC_MAC_WOL PIN_B1
      #define ENC_MAC_USE_SPI TRUE      //due to an errata in the ENC28J60, you should always use HW SPI to assure that SPI clock is over 8MHz!
      #define mac_enc_spi_tris_init()  TRISB=(TRISB | 0b11); TRISC = (TRISC & 0b11010111) | 0x10; TRISD=TRISD & 0xF4 //was 0xFC

   #elif STACK_USE_CCS_OLXMINI
      #define PIN_ENC_MAC_SO  PIN_C4   // PIC <<<< ENC
      #define PIN_ENC_MAC_SI  PIN_C5   // PIC >>>> ENC
      #define PIN_ENC_MAC_CLK PIN_C3
      #define PIN_ENC_MAC_CS  PIN_B3
      #define PIN_ENC_MAC_RST PIN_B5
      #define PIN_ENC_MAC_INT PIN_B2
      #define PIN_ENC_MAC_WOL PIN_B1
      #define ENC_MAC_USE_SPI TRUE      //due to an errata in the ENC28J60, you should always use HW SPI to assure that SPI clock is over 8MHz!
      #define mac_enc_spi_tris_init()  TRISB=(0b110); TRISC = (TRISC & 0b11010111) | 0x10; TRISD=TRISD & 0xF4//was 0xFC

   #elif STACK_USE_CCS_OLXWEB
      #define PIN_ENC_MAC_SO  PIN_C4   // PIC <<<< ENC
      #define PIN_ENC_MAC_SI  PIN_C5   // PIC >>>> ENC
      #define PIN_ENC_MAC_CLK PIN_C3
      #define PIN_ENC_MAC_CS  PIN_B4
      #define PIN_ENC_MAC_RST PIN_B5
      #define PIN_ENC_MAC_INT PIN_B2
      #define PIN_ENC_MAC_WOL PIN_B1
      #define ENC_MAC_USE_SPI TRUE      //due to an errata in the ENC28J60, you should always use HW SPI to assure that SPI clock is over 8MHz!
      #define mac_enc_spi_tris_init()  TRISB=(0b110); TRISC = (TRISC & 0b11010111) | 0x10; TRISD=TRISD & 0xF4//was 0xFC
     
   #elif STACK_USE_CCS_EWL5V
      #define PIN_ENC_MAC_SO  PIN_C4   // PIC <<<< ENC
      #define PIN_ENC_MAC_SI  PIN_C5   // PIC >>>> ENC
      #define PIN_ENC_MAC_CLK PIN_C3
      #define PIN_ENC_MAC_CS  PIN_A4
      #define PIN_ENC_MAC_RST PIN_B5
      #define PIN_ENC_MAC_INT PIN_B2
      #define PIN_ENC_MAC_WOL PIN_B3
      #define ENC_MAC_USE_SPI TRUE      //due to an errata in the ENC28J60, you should always use HW SPI to assure that SPI clock is over 8MHz!
      #define mac_enc_spi_tris_init()  TRISB=(TRISB | 0b00001100)&0b11011111; TRISC = (TRISC & 0b11010111) | 0x10; TRISA=TRISA & 0b11101111

   #elif STACK_USE_CCS_PICEEC||STACK_USE_CCS_EWL3V
      //no hardware definitions - everything is internal
   #else
      #error Please define your MAC/NIC I/O settings
   #endif



//// SET TCP_NO_WAIT_FOR_ACK TO FALSE IF TCP STACK SHOULD WAIT FOR ACK FROM
//// REMOTE HOST BEFORE TRANSMITTING ANOTHER PACKET.  THIS MAY REDUCE THROUGHPUT.
//// DEFAULT VALUE (TRUE) GETS LOADED IN TCP.H IF THIS LINE IS REMOVED.
   #define TCP_NO_WAIT_FOR_ACK   FALSE


///DEFAULT HARDCODED IP ADDRESSES.
///  FUTURE APPLICATIONS MAY WANT TO SAVE THESE TO AN EEPROM.
///  OR USE AUTO IP ASSIGNMENT (DHCP).
///  NO TWO DEVICES ON A NETwORK CAN HAVE THE SAME IP ADDRESS
   #define MY_DEFAULT_IP_ADDR_BYTE1        10   //IP ADDRESS
   #define MY_DEFAULT_IP_ADDR_BYTE2        10   // This unit's IP address.
   #define MY_DEFAULT_IP_ADDR_BYTE3        5
   #define MY_DEFAULT_IP_ADDR_BYTE4        15

   #define MY_DEFAULT_MASK_BYTE1           0xff //NETMASK
   #define MY_DEFAULT_MASK_BYTE2           0xff // Netmask tells the IP / ARP stack which
   #define MY_DEFAULT_MASK_BYTE3           0xff // IP's are on your local network.
   #define MY_DEFAULT_MASK_BYTE4           0x00

   #define MY_DEFAULT_GATE_BYTE1           192  //GATEWAY IP ADDRESS
   #define MY_DEFAULT_GATE_BYTE2           168  // Gateway acts as a conduit between two networks.
   #define MY_DEFAULT_GATE_BYTE3           100
   #define MY_DEFAULT_GATE_BYTE4           1

///DEFAULT HARDCODED MAC ADDRESS.
///  FUTURE APPLICATIONS MAY WANT TO SAVE THIS TO AN EEPROM, OR GENERATE
///  A DYNAMIC ONE BASED UPON UNIT'S SERIAL NUMBER.
///  NO TWO DEVICES ON THE SAME ETHERNET NETWORK CAN HAVE THE SAME MAC ADDRESS.
#define MY_DEFAULT_MAC_BYTE1            0x00
#define MY_DEFAULT_MAC_BYTE2            0x04
#define MY_DEFAULT_MAC_BYTE3            0xa3
#define MY_DEFAULT_MAC_BYTE4            0x00
#define MY_DEFAULT_MAC_BYTE5            0x00
#define MY_DEFAULT_MAC_BYTE6            0x00

///Maximum sockets to be defined.
/// Note that each socket consumes 36 bytes of RAM.
/// If you remove this, a default value will be loaded in stacktsk.h
   #ifndef MAX_SOCKETS
   #define MAX_SOCKETS                     5
   #endif

///Avaialble UDP Socket
/// DCHP takes 1 socket.
/// If you remove this, a default value will be loaded in stacktsk.h
   #ifndef MAX_UDP_SOCKETS
   #define MAX_UDP_SOCKETS                 2
   #endif

///BUFFER SIZE DEFINITIONS
///
/// For SLIP, there can only be one transmit and one receive buffer.
/// Both buffer must fit in one bank.  If bigger buffer is required,
/// you must manually locate tx and rx buffer in different bank
/// or modify your linker script file to support arrays bigger than
/// 256 bytes.
/// I think Microchip needs MAC_RX_BUFFER_SIZE to equal MAC_TX_BUFFER_SIZE
///
/// For PPP, there can only be one transmit and one receive buffer.
/// You can receive messages larger than the receive buffer if your
/// routines are fast enough.  You cannot transmit messages larger
/// than the TX buffer.  The larger the buffer you can make, the better.
/// BUG: MAC_RX_BUFFER_SIZE must equal MAC_TX_BUFFER_SIZE
///
/// For Ethernet, the Ethernet controler has many buffers that are
/// 1k in size.   Only one buffer is used for TX, rest are for RX.
/// Unlike SLIP and PPP, no RAM is used for these buffers.
   #if STACK_USE_MAC
       #define MAC_TX_BUFFER_SIZE          1024 //do not modify this line
       #define MAC_TX_BUFFER_COUNT         1    //do not modify this line
   #elif STACK_USE_PPP
       #define MAC_TX_BUFFER_SIZE          1024
       #define MAC_TX_BUFFER_COUNT         1
   #elif STACK_USE_SLIP
       #define MAC_TX_BUFFER_SIZE          250
       #define MAC_TX_BUFFER_COUNT         1
   #endif

   #define MAC_RX_BUFFER_SIZE              MAC_TX_BUFFER_SIZE  //do not modify this line unless you are certain you know what you're doing

#endif


The test code looks like this:
Code:

#define STACK_USE_ICMP  1
#define STACK_USE_ARP   1
#define STACK_USE_DHCP  1
//#define MPFS_USE_PGRM 1

#include "ccstcpip.h"

#define LED pin_d5
#define DISPLAYWAIT  1     // seconds

void LCDTask(void) {
   // no LCD on mini-web so continue with serial output
   static TICKTYPE lastTick;
   static enum {LCD_Display=0, LCD_Wait=1} state=0;

   switch(state) {
      case LCD_Display:
         if (!MACIsLinked()) {
            printf("No Ethernet\n");
         }
         else if (!DHCPIsBound()) {
            printf("DCHP Not Bound\n");
         }
         else {
            printf("%u.%u.%u.%u\n", MY_IP_BYTE1, MY_IP_BYTE2,
               MY_IP_BYTE3, MY_IP_BYTE4);
         }
         lastTick=TickGet();
         state=LCD_Wait;
         break;

      case LCD_Wait:
         if (TickGetDiff(TickGet(), lastTick) >= TICKS_PER_SECOND * DISPLAYWAIT)
            state=LCD_Display;
         break;
   }
}

void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_oscillator(FALSE);
   while( 1 )
   {
      delay_ms(100);       // allow some settle time
      printf("CCS TCP/IP TUTORIAL, EXAMPLE 11 (DHCP)\r\n");
      MACAddrInit();
       printf("MACAddrInit, done\r\n");
      StackInit();
      printf("StackInit, done\r\n");
   
      while(TRUE) {
         StackTask();
         LCDTask();
      }
   }

}



The problem is: afer StackTask has been called a few times the PIC will reset. Am I forgetting something? I used http://www.ccsinfo.com/forum/viewtopic.php?t=37139 as an example for my code.

Compiler version 4.088
_________________
checkout my site: www.ymoona.com/wiki
ymoona



Joined: 20 Mar 2005
Posts: 32
Location: Heiloo, the Netherlands

View user's profile Send private message Visit poster's website

PostPosted: Sun Jul 26, 2009 2:34 pm     Reply with quote

#define PIN_ENC_MAC_CS PIN_B4
must be
#define PIN_ENC_MAC_CS PIN_B3

now it works
_________________
checkout my site: www.ymoona.com/wiki
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group