caramoan tour package

caramoan tour package

Author Topic: MikroC's SPI Ethernet ENC28J60 Library  (Read 9710 times)

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #220 on: May 19, 2012, 07:46:10 PM »
Eto nga po pala yung pin configuration na sinunod ko sir.

http://www.dz863.com/pinout-81308263-PIC18F2620/
Computer Engineering National Organization registration thread


Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #220 on: May 19, 2012, 07:46:10 PM »

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #221 on: May 19, 2012, 07:46:53 PM »
Please post mo yung buong codes mo prof para matingnan natin.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #221 on: May 19, 2012, 07:46:53 PM »

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #222 on: May 19, 2012, 07:48:22 PM »
Eto po sir:

Code: [Select]
// duplex config flags
#include  "__EthEnc28j60.h"

#define Spi_Ethernet_HALFDUPLEX     0x00  // half duplex
#define Spi_Ethernet_FULLDUPLEX     0x01  // full duplex

// mE ehternet NIC pinout
sfr sbit SPI_Ethernet_Rst at LATC0_bit;  // for writing to output pin always use latch (PIC18 family)
sfr sbit SPI_Ethernet_CS  at LATC1_bit;  // for writing to output pin always use latch (PIC18 family)
sfr sbit SPI_Ethernet_Rst_Direction at TRISC0_bit;
sfr sbit SPI_Ethernet_CS_Direction  at TRISC1_bit;
// end ethernet NIC definitions


/************************************************************
 * ROM constant strings
 */
const code unsigned char httpHeader[] = "HTTP/1.1 200 OKnContent-type: " ;  // HTTP header
const code unsigned char httpMimeTypeHTML[] = "text/htmlnn" ;              // HTML MIME type
const code unsigned char httpMimeTypeScript[] = "text/plainnn" ;           // TEXT MIME type
unsigned char httpMethod[] = "GET /";


char automation[] =
"<HTML>
<title>ASIMO</title>
<HEAD></HEAD>
<BODY>
<center>
<a href="http://s1262.photobucket.com/albums/ii604/asimo69/?action=view&amp;current=logo.png" target="_blank"><img src="http://i1262.photobucket.com/albums/ii604/asimo69/logo.png" border="0" alt="Photobucket"></a>
<script src=/s></script>
<table width="500" border="0">
<tr>
<td colspan="2" style="background-color:#FFA500;">
<h1 align="center">SWITCH VIA ETHERNET</h1>
</td>
</tr>
<tr valign="top">
<br>
<form name="input" action="/" method="get">
<td align=center bgcolor=#FFD700>
<input name="1" type="submit" value="ON"></td>
<td align=center bgcolor=#FFD700>
<input name="1" type="submit" value="OFF"></td>
</tr>
</FORM>
</td>
</tr>
</center>
<tr>
<td colspan="2" style="background-color:#FFA500;text-align:center;">
Copyright © <a href=http://www.electronicslab.ph/forum/>[url=http://www.electronicslab.ph]www.electronicslab.ph[/url]</a>
</tr>
</table>
</body>
</html>
" ;


/***********************************
 * RAM variables
 */
unsigned char   myMacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f} ;   // my MAC address
unsigned char   myIpAddr[4]  = {192, 168, 2, 60 } ;                   // my IP address
unsigned char   gwIpAddr[4]  = {192, 168, 2, 144 } ;                   // gateway (router) IP address
unsigned char   ipMask[4]    = {255, 255, 255, 0 } ;                   // network mask (for example : 255.255.255.0)
unsigned char   dnsIpAddr[4] = {192, 168, 2, 1 } ;                   // DNS server IP address

unsigned char   getRequest[15] ;                                        // HTTP request buffer
unsigned char   dyna[29] ;                                              // buffer for dynamic response
char color1[] = "#FFFF00";                                              // Color yellow. More colors @ http://www.computerhope.com/htmcolor.htm
char color2[] = "#4974E2";                                              // Color blue

#define putConstString  SPI_Ethernet_putConstString
#define putString  SPI_Ethernet_putString


unsigned int  SPI_Ethernet_UserTCP(unsigned char *remoteHost, unsigned int remotePort, unsigned int localPort, unsigned int reqLength, TEthPktFlags *flags)
        {
        unsigned int    len;            // my reply length

        if(localPort != 80)                         // I listen only to web request on port 80
                {
                return(0) ;
                }

        // get 15 first bytes only of the request, the rest does not matter here
        for(len = 0 ; len < 15 ; len  )
        {
        getRequest[len] = SPI_Ethernet_getByte() ;
        }
        getRequest[len] = 0 ;
        len = 0;


        if(memcmp(getRequest, httpMethod, 5))       // only GET method is supported here
                {
                return(0) ;
                }
        if(!memcmp(getRequest 6, "1=ON", 4))   // do we have ON command
                 LATC6_bit=1;
        if(!memcmp(getRequest 6, "1=OFF", 5))     // do we have OFF command
                 LATC6_bit=0;

                 len =  putConstString(httpHeader) ;             // HTTP header
                 len  = putConstString(httpMimeTypeHTML) ;       // with HTML MIME type
                 len  = SPI_Ethernet_putString(automation) ;

        if(len == 0)                                            // what do to by default
                {
                len =  putConstString(httpHeader) ;             // HTTP header
                len  = putConstString(httpMimeTypeHTML) ;       // with HTML MIME type
                len  = SPI_Ethernet_putString(automation) ;
                }

        return(len) ;                                           // return to the library with the number of bytes to transmit
        }

unsigned int  SPI_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqLength, TEthPktFlags *flags)
        {
        return(0) ;           // no UDP reply
        }

/*
 * main entry
 */
long i;
void    main()
        {
        CMCON |=7;              // Comparators off (see pp. 236 of the datasheet)
        ADCON1 = 0x0F ;         // ADC convertors not will be used  (see pp. 226 of the datasheet)
        PORTA = 0;              // initialize PORTA to all low
        TRISA = 0x00 ;          // set PORTA as output (see pp. 93 of the datasheet)
        TRISC.B0 =0;            // PORTC.B0 is output. This is the reset pin for the ENC.
        TRISC.B1 =0;            // PORTC.B1 is output. This is the chip select(CS) pin.
        PORTB = 0 ;             // initialize PORTB to all low
        TRISB = 0x00 ;          // set PORTB as output (see pp. 96 of the datasheet)
        TRISC.B6 =0;
        /*
         * starts ENC28J60 with :
         * reset bit on RC0
         * CS bit on RC1
         * my MAC & IP address
         * full duplex
         */
        SPI1_Init();
        SPI_Rd_Ptr = SPI1_Read;
        SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
        // dhcp will not be used here, so use preconfigured addresses
        SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr) ;

        while(1)                            // do forever
                {
                /*
                 * if necessary, test the return value to get error code
                 */
                SPI_Ethernet_doPacket() ;   // process incoming Ethernet packets
                }
        }

Yung sa HTML po na part, meron po yang backslash.
Computer Engineering National Organization registration thread


Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #222 on: May 19, 2012, 07:48:22 PM »

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #223 on: May 19, 2012, 07:59:28 PM »
Code: [Select]

void    main()
        {
        CMCON |=7;              // Comparators off (see pp. 236 of the datasheet)
        ADCON1 = 0x0F ;         // ADC convertors not will be used  (see pp. 226 of the datasheet)
        PORTA = 0;              // initialize PORTA to all low
        TRISA = 0x00 ;          // set PORTA as output (see pp. 93 of the datasheet)
        TRISC.B0 =0;            // PORTC.B0 is output. This is the reset pin for the ENC.
        TRISC.B1 =0;            // PORTC.B1 is output. This is the chip select(CS) pin.
        PORTB = 0 ;             // initialize PORTB to all low
        TRISB = 0x00 ;          // set PORTB as output (see pp. 96 of the datasheet)
        TRISC.B6 =0;
        UART1_Init(9600);               // Initialize UART module at 9600 bps
        Delay_ms(100);                  // Wait for UART module to stabilize
 
        UART1_Write_Text("1234567891bcdefg");
        Delay_ms(100); 
        UART1_Write_Text("1234567891bcdefg");
        /*
         * starts ENC28J60 with :
         * reset bit on RC0
         * CS bit on RC1
         * my MAC & IP address
         * full duplex
         */
        SPI1_Init();
        SPI_Rd_Ptr = SPI1_Read;
        SPI_Ethernet_Init(myMacAddr, myIpAddr, Spi_Ethernet_FULLDUPLEX) ;
        // dhcp will not be used here, so use preconfigured addresses
        SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr) ;

        while(1)                            // do forever
                {
                /*
                 * if necessary, test the return value to get error code
                 */
                SPI_Ethernet_doPacket() ;   // process incoming Ethernet packets
                }
        }


Palitan mo yang void main nito prof.
At enable mo ang Uart sa Library manager sa right side.
Dapat pag restart ng hardware mo, mag blink ang LED ng saglit.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #223 on: May 19, 2012, 07:59:28 PM »

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #224 on: May 19, 2012, 08:07:39 PM »
Umiilaw nga yung LED sir. :)

Pero, di po namamatay.
Computer Engineering National Organization registration thread


Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #224 on: May 19, 2012, 08:07:39 PM »

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #225 on: May 19, 2012, 08:13:20 PM »
Magtatanong lang po ako dito na lines sir:

Code: [Select]
if(!memcmp(getRequest+6, "1=ON", 4))   // do we have ON command
                 LATC6_bit=1;
if(!memcmp(getRequest+6, "1=OFF", 5))     // do we have OFF command
                 LATC6_bit=0;

                 len =  putConstString(httpHeader) ;             // HTTP header
                 len += putConstString(httpMimeTypeHTML) ;       // with HTML MIME type
                 len += SPI_Ethernet_putString(automation) ;

Pwede po bang ito yung gawin ko:

Code: [Select]
if(!memcmp(getRequest+6, "1=ON", 4))   // do we have ON command
        {         
                 LATC6_bit=1;
                 len =  putConstString(httpHeader) ;             // HTTP header
                 len += putConstString(httpMimeTypeHTML) ;       // with HTML MIME type
                 len += SPI_Ethernet_putString(automation) ;
        }
if(!memcmp(getRequest+6, "1=OFF", 5))     // do we have OFF command
        {         
                 LATC6_bit=0;
                 len =  putConstString(httpHeader) ;             // HTTP header
                 len += putConstString(httpMimeTypeHTML) ;       // with HTML MIME type
                 len += SPI_Ethernet_putString(automation) ;
        }
Computer Engineering National Organization registration thread


Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #226 on: May 19, 2012, 08:16:56 PM »
Try mo lang prof, hindi masira yan.
Pero parang mukhang pareho lang yan.

Umiilaw nga yung LED sir. :)

Pero, di po namamatay.

Kasi naka inverted ang signal sa UART. ;D ;D

Alisin mo na yung sa UART prof.

The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #227 on: May 19, 2012, 08:22:22 PM »
Ayaw parin.

White flag muna ako sir. :D Bukas na naman siguro. Ako nalang kasi yung tao dito sa school eh.
Computer Engineering National Organization registration thread


Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #228 on: May 19, 2012, 08:25:28 PM »
Ako din masakit na ang ulo ko sa gutom.
Na stress ako kanina sa assignment ni master. ;D ;D
Huwag kang mag-alala kunting problema lang yan.
Ang importante ok lang ang ENC mo.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #229 on: May 19, 2012, 08:27:25 PM »
Ako din masakit na ang ulo ko sa gutom.
Na stress ako kanina sa assignment ni master. ;D ;D
Huwag kang mag-alala kunting problema lang yan.
Ang importante ok lang ang ENC mo.

Tama nga po sir. ;D Buti't nakuha mo yung assignment. ;D Sosolve ko lang to bukas or Monday. Sira kasi HDD ng laptop ko eh. ;D

Nasaan na kaya si boy femfem? ;D ;D ;D
Computer Engineering National Organization registration thread


Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #230 on: May 19, 2012, 08:33:20 PM »
Nandoon yon sa kumander niya nagluluto ng hapunan or naglalaba. ;D ;D

Pero napailaw daw niya yung LED.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #231 on: May 19, 2012, 08:34:36 PM »
Nandoon yon sa kumander niya nagluluto ng hapunan or naglalaba. ;D ;D

Pero napailaw daw niya yung LED.

Mabuti naman kung ganoon. ;D Eto nga rin po yung nangyari skin sir eh. Napailaw ko rin yung LED. Then, after nun, eto na yung problema. Ayaw nya ng gumana.
Computer Engineering National Organization registration thread


Offline carlsberg11

  • Lead Acid Battery
  • *******
  • Posts: 526
  • Pogi/Ganda Points: 30
  • Gender: Male
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #232 on: May 19, 2012, 08:44:38 PM »
learning camtasia right now, para naman swabe mga vids na papakita ko. :D :D :D , medyo may idea na ako sa LCD interfacing with its scrolling but not through ENC module.. :D :D :D

camtasia mode muna :D
Anyone who has never made a mistakes has never tried anything new.

-Albert Einstein

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #233 on: May 19, 2012, 08:50:09 PM »
Sa site nila sir carlsberg marami tutorial doon.

The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline carlsberg11

  • Lead Acid Battery
  • *******
  • Posts: 526
  • Pogi/Ganda Points: 30
  • Gender: Male
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #234 on: May 19, 2012, 08:56:46 PM »
Sa site nila sir carlsberg marami tutorial doon.



opo opo, dun nga po master!! :D :D  tapos ko po gawa ng vid try ko po gawin yung reset master lurker... :D :D :D
Anyone who has never made a mistakes has never tried anything new.

-Albert Einstein

Offline carlsberg11

  • Lead Acid Battery
  • *******
  • Posts: 526
  • Pogi/Ganda Points: 30
  • Gender: Male
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #235 on: May 19, 2012, 09:33:50 PM »
prof same tayo ng prob, mukhang indi ko na rin ma open yung turning on LED :( pero ok naman yung program na binigay ni sir picuser, yung default same goes sa dun sa example ng mikroc.. ano solution mo dito prof?
Anyone who has never made a mistakes has never tried anything new.

-Albert Einstein

Offline carlsberg11

  • Lead Acid Battery
  • *******
  • Posts: 526
  • Pogi/Ganda Points: 30
  • Gender: Male
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #236 on: May 19, 2012, 10:21:50 PM »


mga master at sirs! ito na po oh! pag pasensyahan nyo na naka breadboard lang at first time to used c*mt*si*... :D :D :D

credits to sir picuser, sir lurker and prof! :D :D +1 sa inyong lahat!
Anyone who has never made a mistakes has never tried anything new.

-Albert Einstein

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #237 on: May 19, 2012, 11:16:25 PM »
Hindi ko makita ang video sir, CP mode kasi ako ngayon e. Natagalan ka ata sa paglalaba sa bahay ni komander a. ;D

Hindi ko pa yun na-solve sir. Hinihintay ko pa ang reaction ni master picuser sa code kung tama ba talaga hinala ko. Kung i-da-download ko na kasi yung code na kasali yung line na naipost ko na dito, wala syang reply sa ping ko. Pero kung tatanggalin ko yun, owkey naman sya. Tama naman siguro PIC model ko at clock speed na 32MHz sa microC e. Baka may dahilan talaga to. ;D
Computer Engineering National Organization registration thread


Offline carlsberg11

  • Lead Acid Battery
  • *******
  • Posts: 526
  • Pogi/Ganda Points: 30
  • Gender: Male
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #238 on: May 19, 2012, 11:20:09 PM »
Hindi ko makita ang video sir, CP mode kasi ako ngayon e. Natagalan ka ata sa paglalaba sa bahay ni komander a. ;D

Hindi ko pa yun na-solve sir. Hinihintay ko pa ang reaction ni master picuser sa code kung tama ba talaga hinala ko. Kung i-da-download ko na kasi yung code na kasali yung line na naipost ko na dito, wala syang reply sa ping ko. Pero kung tatanggalin ko yun, owkey naman sya. Tama naman siguro PIC model ko at clock speed na 32MHz sa microC e. Baka may dahilan talaga to. ;D

tomo prof! naglaba pa ako sa kay komander, nag saing at nag hain :D :D :D busy e.. :o :o :o

kagabi ko nga inedit yung codes ni sir lurker... nahirapan din ako mag ON at mag off, but mostly sa pag display nung HTML or webpage talaga....advance na ata kayo ni sir lurker prof.. on off palang ako ng LED oh.. :o :o :o


EDIT:
ay prof na ping ko na pala .... :D :D :D
Anyone who has never made a mistakes has never tried anything new.

-Albert Einstein

Offline ΔЅịMø

  • Gas Turbine
  • **
  • Posts: 2903
  • Pogi/Ganda Points: 140
  • Gender: Male
  • "Live Curious"
Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #239 on: May 19, 2012, 11:27:09 PM »
Didiscuss palang ni sir lurker yung mag-change ng color kung na-click mo na. Hindi kasi ako makagawa nung reset dahil sa nangayi.. Umiinit din ba regulator mo sir kung ikakabit na ang enc?
Computer Engineering National Organization registration thread


Philippine Electronics Forum

Re: MikroC's SPI Ethernet ENC28J60 Library
« Reply #239 on: May 19, 2012, 11:27:09 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com