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 CCS Technical Support

PICDEM.net 2 ENC28J60 HW config with CCS TCP/IP Stack

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



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PICDEM.net 2 ENC28J60 HW config with CCS TCP/IP Stack
PostPosted: Mon Jul 23, 2007 3:55 pm     Reply with quote

I am looking to develop some firmware that needs to use ethernet. I have some experience with CCS's TCP/IP stack, and while it's basically what Microchip's is, I have worked with it and have had success with it. Has anyone modified the stack to include the picdem.net 2 board? Namely the TRIS configuration of the pins. I am having trouble with it.

Thanks for the help.
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Tue Jul 24, 2007 1:09 pm     Reply with quote

Here is the code that I have. The top part is the code from CCS that specifies the I/O for the ENC28J60 on their development board. The bottom portion is the code from microchip configured for the picdem.net 2 board, I belive it is in Micro C18.

I would like to configure the CCS code so I can use the pinouts specified in the C18 code. I am having trouble understanding the last line of the CCS code, with the "#define mac_enc_spi_tris_init()..." and how this relates to the tristate configuration in the lower portion.

Code:
//PIN I/O for ethernet development board, from CCS
      #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()  *0xF93=(*0xF93 | 0b11); *0xF94 = (*0xF94 & 0b11010111) | 0x10; *0xF95=*0xF95 & 0xFC

//PIN I/O for PICDEM.net 2 board, from Microchip (C18 compiler perhaps?)
   // ENC28J60 I/O pins
   #define ENC_RST_TRIS      (TRISDbits.TRISD2)   // Not connected by default
   #define ENC_RST_IO      (LATDbits.LATD2)
   #define ENC_CS_TRIS   (TRISDbits.TRISD3)
   #define ENC_CS_IO      (LATDbits.LATD3)
   #define ENC_SCK_TRIS   (TRISCbits.TRISC3)
   #define ENC_SDI_TRIS   (TRISCbits.TRISC4)
   #define ENC_SDO_TRIS   (TRISCbits.TRISC5)
   #define ENC_SPI_IF      (PIR1bits.SSPIF)
   #define ENC_SSPBUF      (SSP1BUF)
   #define ENC_SPISTAT   (SSP1STAT)
   #define ENC_SPISTATbits   (SSP1STATbits)
   #define ENC_SPICON1   (SSP1CON1)
   #define ENC_SPICON1bits   (SSP1CON1bits)
   #define ENC_SPICON2   (SSP1CON2)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 24, 2007 3:42 pm     Reply with quote

Code:

#define mac_enc_spi_tris_init()              \
*0xF93 =  (*0xF93 | 0b11);                   \
*0xF94 =  (*0xF94 & 0b11010111) | 0x10;      \
*0xF95 =   *0xF95 & 0xFC

The addresses given above refer to the TRISB, TRISC, and TRISD
registers, respectively.

The code is either clearing or setting bits in those registers.
For example, 0xF93 is the TRISB register. The line for it
sets bits TRISB.0 and TRISB.1 to a logic 1. This makes pins
B0 and B1 as inputs. It leaves the other bits unchanged.

An AND operation will clear any bits that are set to 0 in the bitmask.
An OR operation will set any bits high, that are set to a 1 in the bitmask.
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