No puedo hacer ping con un ejemplo que encontré de Mikrobasic

Estoy utilizando el modulo de enc28j60 y el pic 18f4550.
el codigo original en este enlace.
aparece hasta abajo!!!!
Y el codigo que he hecho es el siguiente solo lo cambie para poder utilizarlo con el pic18f4550 y la version 4.1:


Código:
------------------PRINCIPAL--------------------------------------------------
program lcd_2
                     \' Lcd module connections
include "home_auto_utils"

dim 
myMacAddr as byte[6] \' my MAC address
myIpAddr as byte[4]  \' my IP address
gwIpAddr as byte[4]  \' gateway (router) IP address
ipMask as byte[4]    \' network mask (for example : 255.255.255.0)
dnsIpAddr as byte[4] \' DNS server IP address

dim SPI_Ethernet_RST as sbit at RC0_bit
dim SPI_Ethernet_CS as sbit at RC1_bit
dim SPI_Ethernet_RST_Direction as sbit at TRISC0_bit
dim SPI_Ethernet_CS_Direction as sbit at TRISC1_bit

const SPI_Ethernet_HALFDUPLEX = 0
const SPI_Ethernet_FULLDUPLEX = 1


main:
ADCON1 = 0x0F        \' no analog inputs
CMCON = 0x07         \' turn off comparators
PORTA.0 = 0
TRISA.0 = 0          \' set PORTB.B0 as output (rele control pin)



indexPage =
"<html><head><title>ELECTRONICA</title></head><body>"+
"<h3 align=center>Sistema de Control Led</h3>"+
"<form name="+Chr(34)+"input"+Chr(34)+" action="+Chr(34)+"/"+Chr(34)+" method="+
Chr(34)+"get"+Chr(34)+"><table align=center width=200 bgcolor=#4974E2 border=2><tr>"+
"<td align=center colspan=2><font size=4 color=white><b>Encender Led</b></font>"+
"</td></tr><tr><td align=center bgcolor=#4974E2><input name="+Chr(34)+"tst1"+
Chr(34)+" width=60 type="+Chr(34)+"submit"+Chr(34)+" value="+Chr(34)+"ON"+
Chr(34)+"></td><td align=center bgcolor=#FFFF00><input name="+Chr(34)+"tst2"+
Chr(34)+" type="+Chr(34)+"submit"+Chr(34)+" value="+Chr(34)+"OFF"+Chr(34)+
"></td></tr></table></form></body></html>"

myMacAddr[0] = 0x00
myMacAddr[1] = 0x14 
myMacAddr[2] = 0xA5
myMacAddr[3] = 0x76 
myMacAddr[4] = 0x19 
myMacAddr[5] = 0x3F

ipMask[0]=255 
ipMask[1]=255 
ipMask[2]=255 
ipMask[3]=0

myIpAddr[0]=192 
myIpAddr[1]=168 
myIpAddr[2]=20 
myIpAddr[3]=60
gwIpAddr[0]=192 
gwIpAddr[1]=168 
gwIpAddr[2]=20 
gwIpAddr[3]=6

dnsIpAddr[0]=192 
dnsIpAddr[1]=168 
dnsIpAddr[2]=20 
dnsIpAddr[3]=1
\' starts ENC28J60 with: reset bit on PORTC.F0, CS bit on PORTC.F1,
\' my MAC & IP address, full duplex
SPI1_Init()
\' full duplex, CRC + MAC Unicast + MAC Broadcast fi ltering


\'SPI_Ethernet_Init (PORTC, 0,PORTC,1, myMacAddr, myIpAddr,
 \'_SPI_Ethernet_FULLDUPLEX)
  SPI_Ethernet_Init(myMacAddr, myIpAddr, SPI_Ethernet_FULLDUPLEX)



\'Spi_Ethernet_Init (myMacAddr, myIpAddr, _Spi_Ethernet_FULLDUPLEX)
\' dhcp will not be used here, so use preconfi gured addresses
SPI_Ethernet_confNetwork(ipMask, gwIpAddr, dnsIpAddr)
while true \' do forever
SPI_Ethernet_doPacket() \' process incoming Ethernet packets
wend
end.
-----------------------------------------------------------------------------
----------------SEGUNDA PARTE--------------------------------------------
module home_auto_utils

const httpHeader as string[31] = "HTTP/1.1 200 OK"+chr(10)+"Content-type: " \' HTTP header
const httpMimeTypeHTML as string[13] = "text/html"+chr(10)+chr(10) \' HTML MIME type
const httpMimeTypeScript as string[14] = "text/plain"+chr(10)+chr(10) \' TEXT MIME type
\' default html page
dim indexPage as string[523]
dim getRequest as byte[20] \' HTTP request buff er

implements

sub function SPI_Ethernet_UserTCP(dim byref remoteHost as byte[4],
dim remotePort, localPort, reqlength as word) as word
dim cnt as word \'‘ my reply length
tmp as string[10]
if(localPort <> 80) then \'‘ I listen only to web request on port 80
result = 0
exit
end if
\'‘ get 10 fi rst bytes only of the request, the rest does not matter here
for cnt = 0 to 14 getRequest[cnt] = SPI_Ethernet_getByte() next cnt
getRequest[cnt] = 0
tmp = "GET /"
if(memcmp(@getRequest, @tmp, 5) <> 0) then \'‘ only GET method
result = 0
exit
end if
tmp = "ON"
if(memcmp(@getRequest+11, @tmp, 2) = 0) then \'‘ do we have ON command
PORTB.0 = 1 \'‘ set PORTB bit0
else
tmp = "OFF"
if(memcmp(@getRequest+11, @tmp, 3) = 0) then \'‘ do we have OFF command
PORTB.0 = 0 \'‘ clear PORTB bit0
end if
end if
if (PORTB.0) then
tmp = "#FFFF00" memcpy(@indexPage+340, @tmp, 6) \'‘ highlight (yellow) ON
tmp = "#4974E2" memcpy(@indexPage+431, @tmp, 6) \'‘ clear OFF
else
tmp = "#4974E2" memcpy(@indexPage+340, @tmp, 6) \'‘ clear ON
tmp = "#FFFF00" memcpy(@indexPage+431, @tmp, 6) \'‘ highlight (yellow) OFF
end if
cnt = Spi_Ethernet_putConstString(@httpHeader) \'‘ HTTP header
cnt = cnt + Spi_Ethernet_putConstString(@httpMimeTypeHTML) \'‘ with HTML MIME type
cnt = cnt + Spi_Ethernet_putString(@indexPage) \'‘ HTML page fi rst part
result = cnt \'‘ return to the library with the number of bytes to transmit
end sub
sub function SPI_Ethernet_UserUDP(dim byref remoteHost as byte[4],
dim remotePort, destPort, reqlength as word) as word
result = 0 \'‘ back to the library with the length of the UDP reply
end sub
end.

Y Para configurar las caracteristicas del mirocontrolador solo me fije en el ejemplo que trae mikrobasi para pic 18\'s y copie:
Estoy utilizando un oscilador de 8MHz.
1.-la frecuencia :32.000hz
2.-oscillador selection: HS oscilador, pll enable(HPLL).
(Estoy utilizando un oscilador de 8MHz.)
Pdt. No se si tenga que ver, pero al tratar de ocupar el pic 18f4550 para encender un LCD 16*2 no puedo hacerlo, sin embargo simulado si me sale!!!! ...

solo quiten las caritas y habran el enlace para ver el ejemplo:

www.mikroe.com/downloads/get/547/es_article_basic_pic_02_09.pdf
 
Última edición por un moderador:
Atrás
Arriba