28j60 + pic 18f452. Test program does not work. Help
28j60 + pic 18f452. Test program does not work. Help
Help please. The program does not work. I will not understand where error.
#define Spi_Ethernet_HALFDUPLEX 0
#define Spi_Ethernet_FULLDUPLEX 1
unsigned char MacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f} ; // my MAC address
unsigned char IpAddr[4] = {192, 168, 1, 60 } ; // my IP address
unsigned char destIpAddr[4]; // IP address
unsigned char transmit = 0 ;
unsigned int destPortNum = 0 ;
char udpStr[16] = "PORTB=" ;
#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)
{
return(0) ;
}
unsigned int Spi_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqLength)
{
switch(Spi_Ethernet_getByte())
{
// begin command
case 'b':
case 'B':
transmit = 1 ; // set transmission flag
memcpy(destIPAddr, remoteHost, 4) ; // save remote host IP addr
destPortNum = remotePort ; // save remote host port number
Spi_Ethernet_putByte('B') ; // reply with 'Begin' string
Spi_Ethernet_putByte('e') ;
Spi_Ethernet_putByte('g') ;
Spi_Ethernet_putByte('i') ;
Spi_Ethernet_putByte('n') ;
return(5) ; // 5 bytes to transmit
// end command
case 'e':
case 'E':
transmit = 0 ; // clear transmission flag
Spi_Ethernet_putByte('E') ; // reply with 'End'
Spi_Ethernet_putByte('n') ;
Spi_Ethernet_putByte('d') ;
return(3) ; // 3 bytes to transmit
// error
default:
Spi_Ethernet_putByte('?') ;
return(1) ;
}
}
void main()
{
ADCON1 = 0x0F; ; // ADC convertors
PORTA = 0 ;
TRISA = 0xff ; // set PORTA as input
PORTB = 0 ;
TRISB = 0xff ; // set PORTB as input
PORTD = 0 ;
TRISD = 0 ; // set PORTD as output
PORTE = 0; // Initialize PORTB
TRISE = 0;
Spi_Init();
Spi_Ethernet_Init(&PORTC, 0, &PORTC, 1, MacAddr, IpAddr, Spi_Ethernet_FULLDUPLEX) ;
while(1) // do forever
{
Spi_Ethernet_doPacket() ; // process incoming Ethernet packets
if(transmit) // transmit one UDP packet per second
{
ByteToStr(PORTB, udpStr + 6) ; // read PORTB value and convert to string
Spi_Ethernet_sendUDP(destIpAddr, 3456, destPortNum, udpStr, sizeof(udpStr)) ;
PORTE = ~PORTE;
Delay_ms(1000);
}
}
}
#define Spi_Ethernet_HALFDUPLEX 0
#define Spi_Ethernet_FULLDUPLEX 1
unsigned char MacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f} ; // my MAC address
unsigned char IpAddr[4] = {192, 168, 1, 60 } ; // my IP address
unsigned char destIpAddr[4]; // IP address
unsigned char transmit = 0 ;
unsigned int destPortNum = 0 ;
char udpStr[16] = "PORTB=" ;
#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)
{
return(0) ;
}
unsigned int Spi_Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqLength)
{
switch(Spi_Ethernet_getByte())
{
// begin command
case 'b':
case 'B':
transmit = 1 ; // set transmission flag
memcpy(destIPAddr, remoteHost, 4) ; // save remote host IP addr
destPortNum = remotePort ; // save remote host port number
Spi_Ethernet_putByte('B') ; // reply with 'Begin' string
Spi_Ethernet_putByte('e') ;
Spi_Ethernet_putByte('g') ;
Spi_Ethernet_putByte('i') ;
Spi_Ethernet_putByte('n') ;
return(5) ; // 5 bytes to transmit
// end command
case 'e':
case 'E':
transmit = 0 ; // clear transmission flag
Spi_Ethernet_putByte('E') ; // reply with 'End'
Spi_Ethernet_putByte('n') ;
Spi_Ethernet_putByte('d') ;
return(3) ; // 3 bytes to transmit
// error
default:
Spi_Ethernet_putByte('?') ;
return(1) ;
}
}
void main()
{
ADCON1 = 0x0F; ; // ADC convertors
PORTA = 0 ;
TRISA = 0xff ; // set PORTA as input
PORTB = 0 ;
TRISB = 0xff ; // set PORTB as input
PORTD = 0 ;
TRISD = 0 ; // set PORTD as output
PORTE = 0; // Initialize PORTB
TRISE = 0;
Spi_Init();
Spi_Ethernet_Init(&PORTC, 0, &PORTC, 1, MacAddr, IpAddr, Spi_Ethernet_FULLDUPLEX) ;
while(1) // do forever
{
Spi_Ethernet_doPacket() ; // process incoming Ethernet packets
if(transmit) // transmit one UDP packet per second
{
ByteToStr(PORTB, udpStr + 6) ; // read PORTB value and convert to string
Spi_Ethernet_sendUDP(destIpAddr, 3456, destPortNum, udpStr, sizeof(udpStr)) ;
PORTE = ~PORTE;
Delay_ms(1000);
}
}
}
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: 28j60 + pic 18f452. Test program does not work. Help
Hello,
Please can you post your entire project here, so we can inspect it.
Best regards.
Please can you post your entire project here, so we can inspect it.
Best regards.
Re: 28j60 + pic 18f452. Test program does not work. Help
This is my project file.
- Attachments
-
- test_ethernet.rar
- (111.21 KiB) Downloaded 247 times
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: 28j60 + pic 18f452. Test program does not work. Help
Hello,
I strongly suggest to upgrade your compiler to latest version of compiler.
Newer version has much improved Ethernet library and also TCP/IP library.
You can use import function from new compiler and check for necessary modifications in Migration document.
This way you will get latest compiler with more features and you will be able to develop projects with those new features.
Best regards.
I strongly suggest to upgrade your compiler to latest version of compiler.
Newer version has much improved Ethernet library and also TCP/IP library.
You can use import function from new compiler and check for necessary modifications in Migration document.
This way you will get latest compiler with more features and you will be able to develop projects with those new features.
Best regards.
Re: 28j60 + pic 18f452. Test program does not work. Help
So what went wrong? I tried the new version of the compiler - the same result. Help me please understand. I apologize in advance for my English. I live in the city of Kharkov in the Ukraine. I speak Russian. In matters related to the ethernet I started. So do not kick me greatly.
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: 28j60 + pic 18f452. Test program does not work. Help
Hello,
Have you tried our example for Ethernet?
Also can you explain what is not working at your example?
Best regards.
Have you tried our example for Ethernet?
Also can you explain what is not working at your example?
Best regards.
Re: 28j60 + pic 18f452. Test program does not work. Help
Hello. For Ethernet I tried your example. Works, but does not suit me. I must realize questioning of port of comptroller at stated intervals and delivery in Ethernet through UDP. In my example at the input of "B" through UDP a terminal comes answer as a line of "Bigin". Nothing takes place further. Questioning of port and delivery of his value is not present. Beforehand thank you.
Re: 28j60 + pic 18f452. Test program does not work. Help
1. Your example is a server Ethernet with my device works fine, but does not suit me.
2. I need the value of port B Pic 18F452 issue through UDP to computer with a certain period.
3. What works in the example: after the character "B" from UDP terminal MikroC, the device the response is "begin".
4. What the example does not work - nothing else works. Issuance of the port is not happening. I think, that don't work function Spi_Ethernet_sendUDP.
WHY ??????
2. I need the value of port B Pic 18F452 issue through UDP to computer with a certain period.
3. What works in the example: after the character "B" from UDP terminal MikroC, the device the response is "begin".
4. What the example does not work - nothing else works. Issuance of the port is not happening. I think, that don't work function Spi_Ethernet_sendUDP.
WHY ??????
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: 28j60 + pic 18f452. Test program does not work. Help
Hello,
Please can you post your project here. The one that you are having troubles with.
Best regards.
Please can you post your project here. The one that you are having troubles with.
Best regards.
Re: 28j60 + pic 18f452. Test program does not work. Help
Hello,
My project file is posted in this thread above.
Best regards.
My project file is posted in this thread above.
Best regards.
Re: 28j60 + pic 18f452. Test program does not work. Help
I have problem with Spi_Ethernet_sendUDP when I am trying to use that function along with serial Ethernet Board, it do not send anything to the PC. The board is working with other functions.
Do you have any working code that implement Spi_Ethernet_sendUDP with PIC18F4550
Thanks
Do you have any working code that implement Spi_Ethernet_sendUDP with PIC18F4550
Thanks
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: 28j60 + pic 18f452. Test program does not work. Help
Hello,saas123qa wrote:I have problem with Spi_Ethernet_sendUDP when I am trying to use that function along with serial Ethernet Board, it do not send anything to the PC. The board is working with other functions.
Do you have any working code that implement Spi_Ethernet_sendUDP with PIC18F4550
Thanks
Please can you tell me which Ethernet library are you using?
Can you confirm that your program exits Spi_Ethernet_sendUDP routine. You can check this in ICD.
Also are you incrementing Net_Ethernet_28j60_userTimerSec variable?
Best regards.
Re: 28j60 + pic 18f452. Test program does not work. Help
I am using the library that come with MikroC Ver 5.3
I confirm that the program exits Spi_Ethernet_sendUDP , because it excute the commands after Spi_Ethernet_sendUDP
No, I am not useing neither Net_Ethernet_28j60_userTimerSec nor SPI_Ethernet_userTimerSec
I confirm that the program exits Spi_Ethernet_sendUDP , because it excute the commands after Spi_Ethernet_sendUDP
No, I am not useing neither Net_Ethernet_28j60_userTimerSec nor SPI_Ethernet_userTimerSec
Re: 28j60 + pic 18f452. Test program does not work. Help
What is the benifit of using Net_Ethernet_28j60_userTimerSec or SPI_Ethernet_userTimerSec?
it is not much clear in the Help
do you have any full example of using Spi_Ethernet_sendUDP
it is not much clear in the Help
do you have any full example of using Spi_Ethernet_sendUDP
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: 28j60 + pic 18f452. Test program does not work. Help
Hello,
Those two variables are same and their function is same.
The only difference between them is that one is from new Ethernet library and other is from old SPI_Ethernet library.
Best regards.
Those two variables are same and their function is same.
The only difference between them is that one is from new Ethernet library and other is from old SPI_Ethernet library.
Best regards.