Hi every body, I am in a bit trouble of finding out the processing time taken by main_tcpnet() function. As it is written in documents that this function must be called periodically but does not specify at how much rate i.e milliseconds. Secondaly since i have other work to do also during interrupt (timer) i wonder how to fix main_tcpnet() function in the same interrupt as doing this causes my hardware to reset. Plz help me Thanx in advance
Surely it would be better to call the function from a task; just like the example(s) given by Keil.
I don't see the need to consider calling it from an ISR.
Thakyou all for reply,
First of all i would say that i m not using RTX kernel, and since calling it from main while(1) making a non periodic call, i am calling it from ISR. And don't worry i am using a timer interrupt of 10msec and even after not doing any thing in ISR except calling main_tcpnet(), my board is getting reset sometime, Thus obviously my que is can any body tell me what is the function of main_tcpnet(), How much time will it take to execute, and on factors does it depends,
Also plz tell me can i do tcpip without using main_tcpnet
aren't there better ways to achieve what you are trying to do? for example, polling a free running hardware timer in your main() 'while' loop and calling 'main_tcpnet()' regularly? or having the hardware timer interrupt the core, set a flag in the timer ISR and polling that one in 'main'? What you are doing is wrong, and probably the cause for your misery.
Quite a number of embedded stacks are intended to be used either in a RTOS thread, or as one of many actions to perform in a while (1) loop.
Hi Michal
What u r saying is the same thing i m doing. Please try to understand following scenario
1) you have set a timer interrupt of say x milli sec 2) after x milli sec you have set a flag in ISR 3) in while(1) u are doing other stuff and say after y milli seconds you poll the flag and called main_tcpnet().
in the above situation first of all ur call to main_tcpnet is not periodic and if y > x main_tcpnet will not work or becomes vey slow.
Dear Devendra,
the uVision help contains many of the answers you are looking for. It is just that it is not so easy to find them.
Reading the help, I can tell that the only function that should be called from an ISR is the timer_tick(), used to give TCPnet an exact indication of time spent.
The main_TcpNet() function should be called very frequently but I personally would not call it from an ISR. The uVision help always shows it running inside a forever loop.
If you want to call it regularly every 10 ms, you can do that also in the forever loop of main() by following the code I attach at the end of my post.
For what regards what TCPnet does, .... the internals of TCPnet is known only by Keil and only recently also by those who purchased the source code of TCPnet.
However, it is possible to understand a lot by simply reading the uVision help.
I give you an example.
If you read the section related to tcp_get_socket, it is written that to run a simple passive socket application the following steps are needed.
It is important to write your own listener() function to do what you want, because main_TcpNet() calls it when one internal event is generated. The listener() function is the way TCPnet allows you to customise operations upon reception of request of connections from a remote client, upon reception of a a valid TCP packet etc.
To make an example, you can customise your listener() function so that your device rejects an attemp of a client to communicate by simply returning 0 upon reception of the TCP_EVT_CONREQ event.
That is only one example of something that main_TcpNet() does. But it is not the only thing.
In general, main_TcpNet() handles the execution of both high level operations (i.e., to send/receive packets, etc...) and also of low level operations (interaction with Ethernet device driver for instance).
You can understand many more behaviours of TCPnet just using your JTAG and placing some breakpoints in your listener() function.
I hope that it can help you to run your first TCPnet application.
Good luck,
Marco.
// this is an extract of code to run on a cortex m3 the function main_TcpNet() every 10ms // stores up to 32 event flags volatile uint32_t event_mask = 0x00000000; const uint32_t eventflag_tcpnet = 0x00000001; int main(void) { for(;;) { // do things..... dothings(); // keep on checking if the systick sends a new event to run main_TcpNet() if(eventflag_tcpnet == (events_mask & eventflag_tcpnet)) { // 1. erase the event. in here you must protect events_mask against // systick interrupt __disable_irq(); events_mask = events_mask & (~eventflag_tcpnet); __enable_irq(); // 2. call tcpnet main_TcpNet(); } // do more things..... domorethings(); } // this isr is called every 1 ms void SysTick_Handler(void) { static uint32_t msec = 0; msec++; if(0 == (msec/10)) { // set the tcpnet event flag event_mask |= eventflag_tcpnet; } if(0 == (msec/100)) // use 100 if TICK_INTERVAL in net_config.c is 100 msec. { timer_tick(); } }
Hello all,
in re-writing the example from some working C code of mine I mistyped a % in SysTick_Handler(). See errata corrige below.
Also, I missed the closing } of the for(;;).
Regards, Marco.
// errata: if(0 == (msec/10)) if(0 == (msec%10)) // corrige ..... ..... // errata: if(0 == (msec/100)) if(0 == (msec%100)) // corrige
Hi Macro
Yes i understood what u have written, But my while loop is too big such that the time i will check the flag may vary from 10ms to 500ms depending upon certain conditions. Certainly with this much delay it will not work.
Secondly help me regarding following:
i programmed MAC to accept only Perfect match address by disabling broadcast. This removes the burden of unwanted interrupts and this works fine. But as soon as i removed the ethernet cable "time out" occurs during ping but when reattached cable still "time out" occurs. And this situations never ends untill i reenable broadcast and dump it into target Plz tell me how to disable broadcast in this situation
it sounds like you have a program design issue at hand. maybe it is better to re-design it, or use an RTOS - that's what they are for, after all:managing priorities and timely servicing different parts of a program.
"...or use an RTOS..."
That would surely be the best option.
You might want to consider/investigate LightingBolt ;)
hi devendra,
if your forever loop takes that time you should seriously consider either to make it shorter by defragmenting actions in more than one iteration or to use an rtos to execute things in parallel.
with an rtos you can make a task with higher priority which regularly wakes up and calls your tcp functions.
About the second problem you have, unfortunately I cannot help much because I havent ever used that feature.
what you should do is to investigate more and post a new question with more details.
good luck, marco.
If the board never responds to broadcasts, how do you find the board when a PC makes a broadcast ARP request to find out which MAC address to use to communicate with ip x.y.z.w?
Hello per
You are right ARP will not work at all if broadcast is disabled, But if this is the case why NXP has given filter feature if it is of no use in such situations
Dear friends,
Yesterday i have cracked the working of all the TCP stuff i.e main_tcpnet() and timer_tick() on LPC2300 using a logic analyzer. Here is the story:
1) Timertick merely provides the time to TCP stack for its time calculations as configured in net_config.c. This is also written above by other members. Nevertheless it does't affect TCP performance as far as i have seen as i am calling timer_tick() aperiodically.
2)Now the whole and sole of TCP is the main_tcpnet() function. As soon as you connect ethernet cable to board it make your code to run in ethrnet interrupt isr depending only upon the traffic and filter configuration.
3)When main_tcpnet() is called it checks for any TCP data arrived (obviously for this to happen ethernet interrupt will ocuur first). If this is the case code will first exit from ethernet interrupt isr and after some microseconds it enters into callback() interrupt in the application code. In callback() isr routine we chk the arrived data and reply acordingly. After completion of this whole process we exit main_tcpnet().
4)Thus the conclusion is main_tcpnet() processing time depends upon ethernet interrupt isr and callback() isr. And callback() interrupt or reply to ping will only occur if we call main_tcpnet() periodically.
Please add you experince to this also
Hello friends, Long time no see, Ok i am in the way of completing my project as i called main_tcpnet() from the while(1) loop. Now in my way i am suffering from hurdles as i asked earlier. My latest hurdle is as follows:
1) I have made 200 servers on LPC2300. A client (can be more then 1) will ask for running data from these servers.
2) I have allocated different IP address to each (Please suggest me a way to dynamically allocate these addresses)
3) Main hurdle is to allocate MAC addresses to each servers, Since the adresses are allocated by IEEE then what should i do to allocate it.
Please suggest me a way
Why not register with IANA?