UDP data send to PC from PIC without PC request

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
sharfudeen
Posts: 12
Joined: 03 May 2018 15:24

UDP data send to PC from PIC without PC request

#1 Post by sharfudeen » 03 May 2018 21:50

Hi, I have faced the problem to send UDP data to PC from PIC32MX795F512L without request from PC.
I wrote simple program
1. Ethernet_doPacket() while loop, whenever send any data from UDP Terminal, PIC send "UDP Transmition" Text.
It is working perfectly.
2. I used one switch which is connected to PORTE Bit 7. Whenever press the switch, Hellow message send to PC.
It is not working, UDP Terminal not receive any message.
I am a new to use pic microcontroller, Please help me. I have given my complete source code.
Please correct me what i made mistake.

unsigned char myMacAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f} ; // my MAC address
unsigned char myIpAddr[4] = {192,168,20,60}; // PIC IP Address
unsigned char IpAddr[4] = {192, 168, 20, 200 }; // My PC IP address
typedef struct {
unsigned canCloseTCP: 1; // flag which closes socket
unsigned isBroadcast: 1; // flag which denotes that the IP package has been received via subnet broadcast address (not used for PIC16 family)
} TEthPktFlags;

unsigned int Ethernet_UserUDP(unsigned char *remoteHost, unsigned int remotePort, unsigned int destPort, unsigned int reqLength, TEthPktFlags *flags)
{
Ethernet_putString("UDP Transmition");
return(15);
}

unsigned int Ethernet_UserTCP(unsigned char *remoteHost, unsigned int remotePort, unsigned int localPort, unsigned int reqLength, TEthPktFlags *flags)
{
return(0); // return to the library with the number of bytes to transmit
}


void main() {
TRISD11_bit = 0; // ETH_ALT_MDC_BIT
TRISD8_bit = 1; // ETH_ALT_MDIO_BIT

TRISA15_bit = 0; // ETH_ALT_TXEN_BIT
TRISD14_bit = 0; // ETH_ALT_TXD0_BIT
TRISD15_bit = 0; // ETH_ALT_TXD1_BIT

TRISG9_bit = 1; // ETH_ALT_RXCLK_BIT
TRISG8_bit = 1; // ETH_ALT_RXDV_BIT
TRISE8_bit = 1; // ETH_ALT_RXD0_BIT
TRISE9_bit = 1; // ETH_ALT_RXD1_BIT
TRISG15_bit = 1; // ETH_ALT_RXERR_BIT

TRISE7_bit = 1; // Switch

Ethernet_Init(myMacAddr, myIpAddr, _ETHERNET_AUTO_NEGOTIATION & _ETHERNET_DEFAULT_MAC);

while (1) {
if (PORTEbits.RE7 == 0){
Ethernet_UserUDP(IpAddr, 10001, 10001, "Hello", 5);
}
Ethernet_doPacket();
}
}

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: UDP data send to PC from PIC without PC request

#2 Post by petar.suknjaja » 07 May 2018 08:10

Hi,
Have you tried the examples for Ethernet library ?
Also could you post here the zipped project files?

Kind regards,
Petar

sharfudeen
Posts: 12
Joined: 03 May 2018 15:24

Re: UDP data send to PC from PIC without PC request

#3 Post by sharfudeen » 07 May 2018 14:44

Dear Peter,
Thanks for your reply.
Please find attached my project.
This project is a testing the UDP transmission, once initiated the udp transmission by send any characters, PIC send "UDP Transmition" text, further on whenever press the push button, PIC should send "Hello" Message.
This is for monitoring purpose, once this project will be success, then i will develop the real project.
Thanks in advance for your support and solution to send the data without request from PC.
Attachments
Main Program 9.rar
(251.21 KiB) Downloaded 152 times

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: UDP data send to PC from PIC without PC request

#4 Post by petar.suknjaja » 09 May 2018 15:42

Can you tell me what development board are you using?

I've tried to test the code that you supplied, but i couldn't get any response in Hercules.
I've captured only once Hello packages, but I couldn't reproduce it anymore.

Kind regards,
Petar

sharfudeen
Posts: 12
Joined: 03 May 2018 15:24

Re: UDP data send to PC from PIC without PC request

#5 Post by sharfudeen » 09 May 2018 19:45

I am using EasyPIC Fusion V7, PIC32MX795F12L MCU card.
I never received Hello message at all.
I used UDP Terminal.

aalqurashi
Posts: 1
Joined: 07 Dec 2021 13:42

Re: UDP data send to PC from PIC without PC request

#6 Post by aalqurashi » 09 Dec 2021 10:03

hello .. i know this is old post .. i have the same issue with the same development board .. have you find a solution to this project ?

Post Reply

Return to “mikroC PRO for PIC32 General”